Skip to content

Field Guide

The strangler fig pattern

Grow the new system around the old one, move one slice of work at a time, and switch the old system off when it has nothing left to do.

Slide: three stages behind a router: start with everything on Gen 1, move slice by slice, then switch Gen 1 off.

A strangler fig starts as a seed in the branches of another tree. It grows down around the trunk, reaches the soil, and over many years takes over completely. Eventually the original tree is gone and the fig is standing in its shape.

Martin Fowler saw strangler figs in the rain forests of Queensland in 2001 and, a couple of years later, wrote a short post using them as a metaphor for replacing software. The name stuck because the idea is easy to hold: you do not knock the old system down. You grow the new one around it.

How it works

There are three moving parts.

Three stages of a strangler fig migration: all traffic to Gen 1, traffic split between Gen 1 and Gen 2, all traffic to Gen 2 1. Before Router Gen 1 does everything 2. During Router Gen 1 shrinking Gen 2 one slice 3. After Router Gen 2 Gen 1 switched off
The router is the whole trick. Once it exists, moving a slice is a routing change, and so is moving it back.
  1. A router in front of the old system. A reverse proxy, an API gateway, a message router, a facade class. Anything that every request passes through and that you control. On day one it sends everything to Gen 1 and changes nothing.
  2. One slice built in the new system. A single screen, endpoint, report or workflow. Small enough to finish in weeks, real enough that people use it.
  3. A routing change. The router starts sending that slice to Gen 2. If it goes wrong, the router sends it back.

Then you repeat steps 2 and 3 until the router has nothing left to send to Gen 1.

Why it works when rewrites do not

  • Something ships every few weeks. The project is never "80% done" for a year. Each slice is in production or it is not.
  • Every step can be undone. Rollback is a routing change, not a restore from backup.
  • You learn the old system as you go. Each slice forces someone to find out what Gen 1 really does for that one piece of behavior. That is a much smaller question than "what does the whole thing do."
  • You can stop. If priorities change with 60% migrated, you have a working system that is 60% better. A rewrite stopped at 60% is worth nothing.
  • Gen 1 can keep changing. Features still ship in the old system for slices that have not moved yet.

Choosing the first slice

Slide: a good first slice is low risk, real, thin on data and visible, and it is not the piece that hurts most.

The first slice exists to prove the plumbing: the router, the deployment pipeline for Gen 2, the monitoring, the rollback. Pick it for that purpose.

A good first slice is:

  • Low risk. Read-only if you can manage it. A report, a lookup, a status page.
  • Real. Used daily by actual people. A slice nobody uses proves nothing.
  • Thin on data. It reads from the old database, or owns a small table of its own.
  • Visible to the people paying for the project. The first slice is also a demonstration.

Resist starting with the piece that hurts most. That piece is usually the most tangled, and the first slice is the wrong time to find out that your router cannot handle sessions.

The hard part is the data

Routing requests is the easy half. The old and new systems still have to agree about data while both are live. There are three common arrangements, in order of how much trouble they cause:

  • Gen 2 reads and writes the old database. Simplest to start, but the new code inherits the old schema and you have not really replaced anything yet. Fine for early slices.
  • Gen 2 owns its data, and the systems synchronize. Each slice moves its tables with it. Something has to keep the two stores consistent for as long as both systems need the data: change data capture, events, or a scheduled sync.
  • Dual write. Both systems write to both stores. It looks simple and is the easiest one to get subtly wrong, because a failure halfway through leaves the stores disagreeing.

Whichever you choose, decide which system is the source of truth for each piece of data at each stage, and write it down. Most strangler migrations that end badly end here.

When not to use it

  • There is no place to route requests and none can be added; see the section above.
  • The system is too small to slice. The router and two deployments cost more than a straight replacement.
  • The data cannot be shared or split between old and new slices.
  • Gen 1 must be gone by a hard date that a slice-by-slice plan cannot meet.

Where it goes wrong

It never finishes. The easy 80% moves and the hard 20% stays, so now there are two systems forever, plus a router. Guard against it by scheduling the hard slices early, and by putting a date on switching Gen 1 off.

The router becomes a system. Business rules creep into the routing layer because it is the one place that sees everything. Keep it stupid. It routes; it does not decide.

The slices are too big. A slice that takes six months is a small rewrite, with all the risk of one. If you cannot ship it in a few weeks, cut it again.

Gen 2 copies Gen 1. Moving code one function at a time into a new language reproduces the old design in a new place. Each slice should be rebuilt to the behavior, not translated from the source.

Nobody owns the old system. While both run, somebody still has to be on call for Gen 1. Teams that move all their best people to Gen 2 learn this at 3 a.m.

When there is nowhere to put a router

A strangler fig needs a trunk to climb. If the old system is a desktop application, or a monolith where every part calls every other part directly, there is no single place that requests pass through.

The related technique for that situation is branch by abstraction, which Martin Fowler wrote up in 2014. Inside the codebase, you introduce an abstraction around the component you want to replace, point every caller at the abstraction, build the new implementation behind it, and switch over. It is the same idea at a smaller scale: create the seam first, then replace what is behind it.

Mozilla replaced Firefox's CSS engine this way. In the words of the engineers who did it, they were "making the changes in place, component by component." The Firefox Quantum case file covers how that went.

Is this the right pattern for you?

It fits when the system has to be replaced, cannot be frozen, and is too large to rebuild in a quarter. It is overkill for something one team could rebuild in a few weeks, and it is the wrong tool when the system does not need replacing at all.

If you are not sure which of those you have, the four options page lays out the decision, and Should we rewrite it? will ask you the questions directly.

Common questions

What is the strangler fig pattern?

A way to replace a system without stopping it. You grow the new system around the old one, move one slice of work at a time, and switch the old system off when it has nothing left to do.

Which part should be moved first?

A slice that is low risk, really used every day, thin on data and visible to the people paying for the project. The first slice exists to prove the plumbing: the router, the deployment pipeline, the monitoring and the rollback. Do not start with the piece that hurts most.

What does the pattern need before it can start?

Somewhere to put a router in front of the old system, so that each request can be sent to the old system or the new one. If there is nowhere to put one, you have to make one first.

Sources

  1. Martin Fowler - Strangler Fig - the origin of the name; the original post was titled Strangler Application
  2. Martin Fowler - Branch By Abstraction (January 7, 2014)
  3. Lin Clark - Inside a super fast CSS engine: Quantum CSS (August 22, 2017) - a browser engine replaced component by component

Last updated November 29, 2026.