Strangler Fig Pattern

Incrementally replacing a legacy system by routing functionality piece by piece to new components, with data synchronization strategies and decommissioning criteria.

Intent

Named by Martin Fowler after strangler fig vines that grow around a host tree, the pattern replaces a legacy system incrementally: put a routing facade in front, build new functionality alongside, redirect traffic capability by capability, and retire legacy parts when they receive no traffic.

flowchart LR
  U[Clients] --> F[Routing facade<br/>gateway / proxy]
  F -->|/catalog/*| NEW1[New catalog service]
  F -->|/search/*| NEW2[New search service]
  F -->|everything else| LEG[Legacy monolith]
  LEG -- CDC --> SYNC[Sync / ACL] --> NEW1
  NEW1 -- events --> LEG2[Legacy adapter<br/>write-back if needed]

Steps

  1. Introduce the facade (API gateway, reverse proxy, edge routing) with zero behaviour change.
  2. Pick a capability with clear boundaries and high value (often read-heavy: catalog, search, reporting).
  3. Build the new component; synchronize data (CDC from legacy, or dual writes via events with reconciliation).
  4. Shadow traffic or run in parallel; compare outputs.
  5. Shift traffic gradually (by percentage, user segment or feature flag).
  6. Make the new component the system of record; reverse sync if legacy still needs the data.
  7. Decommission the legacy code path and data.

Real-world example

A retailer moves product browsing from a 15-year-old Java EE monolith to a new catalog service and Next.js front end. The CDN routes /p/* to the new stack for 5%, then 50%, then 100% of users; CDC keeps catalog data in sync; after three months the monolith's catalog module is deleted.

Pros and cons

Pros Cons
Lower risk than big-bang rewrites Coexistence period adds complexity
Delivers value incrementally Data synchronization and dual ownership are hard
Allows learning and course correction Legacy may never be fully retired without discipline

Interview questions

What is the hardest part of a strangler migration?

Data ownership: deciding which system is the source of truth at each phase and keeping data consistent during coexistence, plus finishing the last 20% so legacy can actually be switched off.

How do you decide which capability to extract first?

High business value or high pain, clear boundaries, few dependencies, manageable data, and something that builds platform capabilities (CI/CD, observability) for later extractions.