The strangler fig pattern is a migration strategy in software architecture that replaces a legacy system incrementally by building new functionality around it, redirecting requests feature by feature, and retiring old code only when nothing depends on it any longer. Instead of a single high-risk rewrite, the old and new systems run side by side behind a routing layer until the legacy application has been fully absorbed.
The name comes from tropical fig vines that germinate in the canopy of a host tree, send roots to the ground and slowly envelop the host until it decays and the fig stands on its own. Martin Fowler popularized the metaphor in 2004, and the pattern has since become the default approach for modernizing monolithic applications, especially when a monolith is being decomposed into microservices or a modular monolith.
How the strangler fig pattern works
The pattern works by placing an interception layer in front of the legacy system and moving responsibility for one capability at a time to new code. Clients keep calling the same entry point, so they do not notice which implementation answers a given request. Over many iterations, the share of traffic handled by the legacy system shrinks toward zero.
A typical migration follows a repeating cycle of identify, transform, coexist and eliminate. Each cycle is small enough to ship in weeks rather than years, and each one delivers production value on its own, which is the main reason the pattern reduces delivery risk compared with a big-bang replacement.
| Phase | Main activity | Exit criterion |
|---|---|---|
| Identify | Select a bounded capability with clear inputs and outputs | Scope, owners and success metrics agreed |
| Transform | Build the replacement as a new service or module | New component passes functional and load tests |
| Coexist | Route a growing share of traffic to the new component | Error rates and latency match or beat legacy |
| Eliminate | Remove the legacy code path and its data dependencies | No remaining calls to the old implementation |
The interception layer can take several forms. In web systems it is often an API gateway or reverse proxy that routes by URL path; in internal codebases it can be a facade class, a message router or a feature flag that selects between old and new implementations at runtime.
Routing and data techniques used during migration
Routing decides which implementation serves each request, while data synchronization keeps both implementations consistent during coexistence. Choosing these techniques well matters more than the choice of target technology, because most failed strangler migrations fail at the data boundary rather than in the new code.
| Technique | How it works | Best suited for |
|---|---|---|
| Path-based proxy routing | Gateway forwards selected URL prefixes to the new service | HTTP applications with clear endpoint boundaries |
| Branch by abstraction | An interface hides both implementations inside one codebase | Internal modules without network boundaries |
| Event interception | Messages from a queue are copied or redirected to new consumers | Event-driven architecture and batch pipelines |
| Change data capture | Database changes stream from the legacy store to the new one | Shared data that both systems must read |
| Dark launching | New code processes real traffic but its output is discarded | Verifying correctness before switching users |
Data ownership deserves explicit planning. During coexistence, one system should be the single source of truth for each data entity; dual writes from application code are a frequent source of silent inconsistency and are generally avoided in favor of change data capture or an outbox mechanism.
Strangler fig compared with other modernization approaches
The strangler fig pattern is one of several ways to modernize a legacy application, and it trades speed of completion for continuous delivery and lower risk. The comparison below shows where it sits among the main alternatives.
| Approach | Risk profile | Time to first value | Main drawback |
|---|---|---|---|
| Strangler fig | Low per step | Weeks | Long coexistence and routing overhead |
| Big-bang rewrite | Very high | Months to years | Feature freeze and cutover failure risk |
| Lift and shift | Low | Weeks | Architecture problems move unchanged |
| In-place refactoring | Moderate | Continuous | Limited by the existing structure and stack |
The pattern also relates closely to neighboring concepts. An anti-corruption layer often sits between new services and the legacy model so that old naming and data shapes do not leak into the new design, and a circuit breaker is commonly added so that failures in either implementation do not cascade through the routing layer.
When to apply the pattern and how to sequence it
The strangler fig pattern fits best when a system is too large or too critical to replace at once and when its requests can be intercepted at a clear boundary. It fits poorly when the legacy system is small, when no interception point exists, or when the whole application must change in one coordinated release for regulatory reasons.
Sequencing determines how quickly the migration produces value. Teams usually start with a low-risk, high-learning capability to prove the routing and deployment pipeline, then move to areas that change frequently, because every feature moved there stops adding new legacy code.
| Situation | Recommended choice | Reason |
|---|---|---|
| First migration cycle | Read-only or reporting feature | Proves routing with minimal data risk |
| Frequent change requests | Migrate the volatile module early | Stops investment in code that will be removed |
| Shared core data model | Migrate late, after patterns mature | Highest coupling and rollback complexity |
| Performance bottleneck | Migrate when scalability is blocking | Delivers visible business benefit |
Each step should be reversible through routing alone: if the new component misbehaves, operators switch traffic back to the legacy path without a redeployment. This rollback capability is the practical safety net that makes incremental migration acceptable for systems with strict availability targets.
Limitations and common mistakes
The most serious risk of the pattern is a migration that never finishes. When the easy features have moved and the remaining legacy core is tightly coupled, momentum often fades, leaving the organization to operate two systems indefinitely at a higher total cost than either alone.
- Unclear decommissioning goals: without a dated plan for retiring legacy components, coexistence becomes permanent.
- Routing layer as a bottleneck: a single gateway with heavy custom logic adds latency and becomes a new point of failure.
- Copying the legacy design: rebuilding the old data model in new services preserves the coupling the migration was meant to remove.
- Inconsistent shared data: dual writes without reconciliation produce divergent records that are hard to detect.
- Underestimated observability needs: comparing old and new behavior requires request tracing across both stacks.
Mitigation is mostly organizational. Teams that track the share of traffic still served by legacy code as a visible metric, budget explicitly for decommissioning work and record major routing decisions in architecture decision records tend to finish migrations instead of stalling halfway.
The short version
Replacing an old software system all at once is like rebuilding a busy bridge by closing it for two years. The strangler fig pattern takes another route. A new lane is built next to the old one, traffic is moved over a little at a time, and the old section is removed only when nobody uses it anymore.
Users keep using the same address or app throughout. Behind the scenes, a traffic controller sends each request either to the old code or to the new code. The key takeaway is simple: small, reversible steps replace one risky leap, and if a new part fails, traffic can go back to the old part within minutes.
Where it makes a difference
A regional insurance company runs a fifteen-year-old policy administration monolith that handles quotes, policy changes, billing and claims. A full rewrite was estimated at three years with a long feature freeze, which the business rejected. The architecture team instead places an API gateway in front of the monolith and chooses the quote calculation feature as the first capability to migrate, because it is read-heavy and changes often.
The new quote service runs in dark-launch mode for four weeks, computing prices in parallel and logging differences against the monolith. After mismatches drop below an agreed threshold, the gateway routes 5 percent of quote traffic to it, then 50 percent, then all of it. Billing follows, using change data capture to keep the legacy database synchronized during coexistence.
After about eighteen months, roughly 80 percent of requests reach new services, and the legacy claims module is the only remaining piece. The company has released new products throughout the migration instead of freezing development, and every cutover was reversible by a single routing change.