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

all requests1migrated routes2the rest3data changes4keep in sync5UsersRouting facadepath rules, flagsNew services/invoices, /searchLegacy monolitheverything elseSync events

Strangler Fig system design diagram

  1. Users (client).
  2. Routing facade (gateway): path rules, flags.
  3. New services (service): /invoices, /search.
  4. Legacy monolith (service): everything else.
  5. Sync events (topic).
  6. Step 1: Users → Routing facade: all requests.
  7. Step 2: Routing facade → New services: migrated routes.
  8. Step 3: Routing facade → Legacy monolith: the rest.
  9. Step 4: Legacy monolith → Sync events: data changes.
  10. Step 5: Sync events → New services: keep in sync.
  1. All traffic goes through a routing facade, which was installed first, with every route still pointing at the legacy system.
  2. Routes for capabilities already rebuilt, such as invoices and search, go to the new services.
  3. Everything else still goes to the legacy monolith, unchanged.
  4. While both run, the legacy system publishes data changes as events…
  5. …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.