Digital Transformation
Modernising Legacy Systems Incrementally with the Strangler Fig Pattern
Full rewrites of legacy systems are risky and slow to show value. The strangler fig pattern replaces a system piece by piece while it keeps running. Here is how to plan and execute it.
Kodvexa Engineering · · 7 min read
Many organisations depend on systems that were built a decade or more ago. They still run the business, but they are hard to change, rely on skills that are increasingly scarce and may run on platforms approaching end of support. The obvious response is to rewrite them from scratch. In practice, large rewrites are among the riskiest projects in software: they take longer than planned, must chase a moving target as the old system keeps changing, and deliver no value until the switchover.
The strangler fig pattern, named by Martin Fowler after a plant that grows around a host tree until it can stand on its own, offers an alternative. New functionality gradually replaces the old system, one piece at a time, while both run side by side. Users keep working throughout, and each step delivers something useful.
How the pattern works
The core idea is to place a routing layer, often called a facade, in front of the legacy system. Initially it passes every request straight through. As each capability is rebuilt in the new system, the facade starts sending the relevant requests to the new implementation instead. Over time, more traffic flows to the new system until the legacy one handles nothing and can be switched off.
- Introduce a facade in front of the legacy system without changing behaviour
- Choose a capability to migrate and build it in the new system
- Route the relevant traffic to the new implementation, ideally gradually
- Verify behaviour, monitor closely and keep a quick way to route back
- Remove the corresponding code from the legacy system once confidence is established
- Repeat until the legacy system can be retired
Choosing the facade
The facade depends on how users and other systems interact with the legacy application. For web applications and APIs, a reverse proxy or API gateway is the natural choice, routing by URL path, header or user group. For systems integrated through messages or files, the interception point might be a message broker or the integration layer that consumes those files. For desktop applications, the facade is sometimes the user interface itself, with new screens calling new services while older screens remain unchanged.
Keep the facade simple. It should make routing decisions, not contain business logic. If it grows into a translation layer full of special cases, it becomes another legacy system in its own right.
Deciding what to migrate first
The order of migration has a large effect on whether the programme builds momentum. The first slice should prove the approach and the new platform without putting the business at significant risk.
- Prefer capabilities with clear boundaries and few dependencies on the rest of the legacy system
- Look for areas that change often, as moving them first makes future changes cheaper
- Consider areas with clear pain, such as slow performance or frequent defects, where improvement will be visible
- Avoid starting with the most critical and tangled part of the system, such as the core ledger or scheduling engine
- Favour read-heavy features early, since they are easier to verify and roll back than complex write paths
Handling data
Routing requests is the easy part; data is usually the hardest. While both systems run, they may need to read and write the same information. There are several approaches, and many programmes use more than one at different stages.
Shared database
The new system reads and writes the legacy database directly. This is the quickest way to start and avoids synchronisation, but it couples the new system to the old schema and makes it hard to improve the data model. It works best as a temporary step.
Synchronisation
The new system has its own database, kept in step with the legacy one. Change data capture tools can stream changes from the legacy database as events, which the new system consumes. Synchronisation in both directions is possible but complex, so it helps to establish clear ownership: for each piece of data, one system is the source of truth at any given time.
Anti-corruption layer
Whichever approach you use, place a translation layer between the new system and legacy data structures. This anti-corruption layer converts legacy concepts and formats into the new system's model, so that the new code is not shaped by the old system's quirks and can stay clean after the legacy system is gone.
Releasing safely
Each migration step should be reversible. Because the facade controls routing, switching back to the legacy implementation can be as simple as a configuration change, provided the data remains consistent in both systems.
- Route a small share of traffic or a pilot user group first, then increase gradually
- Run the new and old implementations in parallel where practical, comparing outputs without exposing the new results to users
- Monitor error rates, latency and business metrics specific to the migrated capability
- Agree in advance what conditions trigger a rollback and who decides
Common pitfalls
The strangler fig pattern reduces risk, but it does not remove it. Several problems recur often enough to plan for.
- Never finishing: the last few capabilities are often the hardest, and programmes stall with both systems running indefinitely, which is more expensive than either alone
- Replicating the old design: rebuilding the legacy system's structure in a new language misses the opportunity to simplify
- Neglecting retirement: if old code is not removed after each migration, the legacy system never gets smaller
- Underinvesting in the facade and data layer, which carry the whole programme
- Losing business engagement once the early, visible wins are delivered
Tracking progress explicitly helps. A simple map of every capability, showing whether it is still legacy, in migration or fully replaced, keeps the end goal visible to both engineering and business stakeholders.
When the pattern is not the right fit
Incremental replacement relies on being able to intercept and redirect parts of the system. Very small systems may be simpler to replace in one go. Systems with no meaningful seams, such as a single batch process with no external interface, may need a different approach. Sometimes the right answer is to buy a commercial product rather than rebuild at all. The pattern is a tool, and it should be chosen because it fits the system, not by default.
Conclusion
Modernising a legacy system is as much about managing risk and maintaining trust as it is about technology. The strangler fig pattern lets organisations replace critical systems while continuing to operate, deliver value in stages and learn as they go. With a clear facade, a sensible order of migration, careful handling of data and discipline about retiring old code, it turns an intimidating rewrite into a series of manageable steps.