Replace an old system piece by piece, until nothing of the old one remains.
The Strangler Fig pattern is a safe way to replace an old system. You build the new system piece by piece around the old one, send more and more traffic to the new pieces, and switch the old one off when nothing uses it any more.
The name comes from a real plant. A strangler fig seed lands on a tree and grows roots down around its trunk. Over many years the fig grows bigger and stronger, until it can stand on its own. The old tree inside slowly dies and is gone. The fig took its place, and the forest never had an empty spot.
In software, a big-bang rewrite means building a whole new system in secret for a year or two, then switching on a single day. This is risky: the old system keeps changing while you build, the new one is never tested by real users until the last moment, and if it fails you have nowhere to go back to. Many such rewrites are late, over budget, or cancelled.
The Strangler Fig avoids this. First you put a facade in front of the old system. At the start it sends everything to the old code, so nothing changes for users. Then you build one feature in the new system, test it, and tell the facade to send that feature's requests to the new code. You repeat this until the old system receives no traffic.
| Where the routing lives | How it works | Good and bad |
|---|---|---|
| Reverse proxy or API gateway | Routes by URL path, for example /search goes to new, the rest to old | Most common and simple. Needs a clean URL for each slice. |
| Load balancer rules | Rules on host name, path or header choose the target | Cheap to add. Limited logic. |
| Feature flags in the app | Code checks a flag and calls the old or the new module | Fine-grained, can target users. The routing logic lives in code. |
| Event interception | New code listens to events or changes (for example a change feed from the old database) | Good when there is no clean URL boundary. More moving parts. |
| UI composition | The page is built from pieces, some served by old and some by new | Smooth for user interfaces. Needs careful styling and sessions. |
| Way to slice | Example | Note |
|---|---|---|
| By feature or URL | /search, /reviews, /checkout | The easiest and most common |
| By business area | Orders, Customers, Inventory | Matches teams and data owners |
| By user group | New customers on new code, old customers on old | Good for a safe canary |
| By read, then write | Move reads first, writes later | Reads are low risk and easy to compare |
| By region or tenant | One country or one client at a time | Limits the damage of a bug |
A simplified model. Two slices (Cart and Payments) have a hidden bug in their new version. In a real project you find such bugs with tests, shadow traffic and small canary shares before moving a feature fully.
| Term | Meaning in easy words |
|---|---|
| Legacy system | The old system you want to replace |
| Facade | A layer in front (proxy or gateway) that routes each request to the old or new code |
| Slice | One small, separate piece of function that is moved on its own |
| Seam | A natural border in the old system where it can be cut with little change |
| Big-bang rewrite | Replacing the whole system in one switch after a long hidden build |
| Canary release | Send a small share of real traffic to new code first, then grow it |
| Shadow traffic | A copy of real requests sent to the new code, with answers ignored, to test it |
| Anti-corruption layer | A translation layer that stops the old design leaking into the new code |
| Feature flag | A switch in code or config that turns a feature on or off, or picks old or new |
| Dual write / data sync | Keeping old and new data stores equal while both exist |
| Rollback | Sending traffic back to the old code after a problem |
| Choice | We gain | We lose |
|---|---|---|
| Strangler Fig | Safety, early value, rollback | A longer project and the cost of running both systems |
| Big-bang rewrite | A clean start and a short final cutover | Huge risk, late feedback, no way back |
| Small slices | Very low risk per step | More steps and more routing rules to manage |
| Large slices | Fewer steps | Each step is harder to test and roll back |
| Shared database during the move | Simple at first, no data copying | The new service stays tied to the old schema |
| Separate database per slice | A clean, independent design | Needs data sync and care about consistency |