Strangler Fig
Replace a legacy system piece by piece behind a routing layer, sending more features to the new system over time until the old one can be switched off.
Description
Big-bang rewrites are risky: months or years without delivering value, then one terrifying cutover. The strangler fig, named after a vine that grows around a tree until it replaces it, does the migration incrementally.
A facade or router goes in front of the legacy system first, with every request passing through it unchanged. Then you rebuild one capability at a time in the new system and switch its routes over, starting with something small and low-risk. Each step is reversible, delivers value on its own, and the old system shrinks until nothing routes to it.
System design
Strangler Fig system design diagram
- Users (client).
- Routing facade (gateway): path rules, flags.
- New services (service): /invoices, /search.
- Legacy monolith (service): everything else.
- Sync events (topic).
- Step 1: Users → Routing facade: all requests.
- Step 2: Routing facade → New services: migrated routes.
- Step 3: Routing facade → Legacy monolith: the rest.
- Step 4: Legacy monolith → Sync events: data changes.
- Step 5: Sync events → New services: keep in sync.
- All traffic goes through a routing facade, which was installed first, with every route still pointing at the legacy system.
- Routes for capabilities already rebuilt, such as invoices and search, go to the new services.
- Everything else still goes to the legacy monolith, unchanged.
- While both run, the legacy system publishes data changes as events…
- …so the new services stay in sync without sharing the old database. Route by route, the monolith empties until it can be switched off.
- AWS
- Application Load Balancer or API Gateway path routing; CloudFront behaviours; AWS Migration Hub Refactor Spaces.
- Azure
- API Management or Front Door routing rules; Application Gateway.
- Google Cloud
- Cloud Load Balancing URL maps; Apigee or API Gateway.
When to use it
Use it when
- You're replacing a large legacy system that must keep running throughout.
- You want value and feedback early, not after a multi-year rewrite.
- The system's features can be separated by URL, message type or user group.
Avoid it when
- The system is small enough to rewrite and cut over in a few weeks.
- Requests can't be intercepted or separated, such as a monolithic batch job with no seams.
- You don't actually intend to finish. A half-strangled system with two stacks forever is worse than either.
Pitfalls
- Shared database: the new system reading and writing the legacy tables directly couples the two forever. Sync data through events or an anti-corruption layer.
- Never finishing the last 20%. Track remaining routes and plan the switch-off.
- The router becoming a complex rule engine. Keep routing rules simple (path, feature flag, percentage).
- No rollback path. Keep the old route available until the new one is proven in production.
Alternatives
Big-bang rewrite
Choose it when rarely: the system is small, frozen and well understood.
Anti-Corruption Layer
Choose it when the new system must keep talking to the legacy one; usually used together with the strangler.
Branch by abstraction
Choose it when the change is inside one codebase: introduce an interface, build the new implementation behind it, switch over.