The Modernization Imperative
Legacy systems are not legacy because they are old. They are legacy because they resist change. The cost of modifications grows over time. Knowledge concentrates in fewer people. Dependencies become unclear. Eventually, the system becomes a liability rather than an asset.
But rewriting from scratch fails more often than it succeeds. The big-bang replacement takes years, during which the legacy system continues evolving. By the time the new system is ready, requirements have changed.
The alternative: incremental modernization. Replace pieces while the whole keeps running.
The Strangler Fig Pattern
Named after strangler fig trees that gradually envelop and replace their host trees, this pattern incrementally replaces legacy functionality:
1. Identify a seam: Find a component with clear boundaries that can be extracted. APIs, batch jobs, and UI sections make good starting points.
2. Build the facade: Insert an interception layer between consumers and the legacy system. Initially, all traffic passes through to legacy.
3. Implement the replacement: Build the new functionality behind the facade. It should be functionally equivalent to the legacy behavior.
4. Redirect incrementally: Route traffic to the new implementation, starting with a small percentage. Use feature flags to control the split.
5. Retire the legacy component: Once all traffic routes to the new system and confidence is high, remove the legacy code.
Repeat for each component until the legacy system is fully replaced.
Data Migration Strategies
Data is often the hardest part. Options:
Synchronization: Keep both systems in sync during migration. Write to both, read from new. Complex but allows gradual cutover.
Event sourcing: Capture changes as events. Replay events into the new system. Provides audit trail and repeatability.
Strangler for data: Route writes to new system, reads to legacy (with fallback). Gradually migrate historical data in the background.
Managing Risk
Modernization projects fail when risk is not actively managed:
When to Rewrite Instead
Sometimes strangling is not practical:
Even then, consider rewriting one bounded context at a time rather than everything at once.
Best Practices
Recommended Reading
💬Discussion
No comments yet
Be the first to share your thoughts!
