Strangler fig in practice: modernising a monolith without a big-bang rewrite
Rewrites fail because they deliver nothing until everything is done. The strangler-fig pattern delivers value every sprint. Here is how we apply it.
The strangler-fig pattern, named by Martin Fowler after a vine that gradually grows around a tree, replaces a legacy system piece by piece. New functionality is built alongside the old system, and traffic moves over feature by feature until the legacy code can be switched off.
Step 1: map the seams
Start by identifying business capabilities and their dependencies: customers, accounts, orders, notifications. Look for seams where a capability can be extracted with a clear interface. Data ownership is usually the hardest part, so map which tables each capability reads and writes.
Step 2: put a router in front
Introduce a routing layer — an API gateway, reverse proxy or a façade inside the monolith — that decides per request whether the old or the new implementation handles it. This is what makes incremental, reversible migration possible.
Step 3: extract the first slice
Choose a capability that is valuable but not the most critical. Build it as a new service, synchronise data with change-data-capture or events, and route a small percentage of traffic to it. Compare results between old and new paths before increasing traffic.
Step 4: protect the old system
While migration is ongoing, the legacy system still serves most traffic. Contract tests and automated regression suites prevent the new services from breaking it, and feature flags allow instant rollback.
Step 5: repeat, then decommission
Each slice gets faster as tooling, patterns and confidence grow. When the last capability moves, remove the routing rules and retire the old infrastructure — the most satisfying deployment of the whole programme.
When not to use it
If a system is small, or its business processes are being completely redesigned, a focused rebuild can be faster. For large, business-critical systems that must keep running, the strangler fig is almost always the safer path.