What is the strangler fig pattern?

The strangler fig pattern is a way to replace a legacy system gradually. A routing layer sends each capability to new code once it is ready, until the old system handles nothing and can be switched off.

Also called strangler pattern, strangler fig application, strangler applicationUpdated

A full rewrite asks the business to wait months or years for a replacement that delivers nothing until launch day. The strangler fig pattern avoids that. New code grows around the old system one capability at a time, and each piece goes live as soon as it works.

Where the name comes from

Martin Fowler described the idea in a short post on 29 June 2004, then titled "Strangler Application". He had seen strangler figs in the Queensland rainforest. They seed in the branches of a host tree, send roots down to the soil and slowly replace the tree. In April 2019 he renamed the post "Strangler Fig Application" because "strangler" on its own had lost the botanical link and sounded violent.

So "strangler pattern" and "strangler fig pattern" are the same thing. The fig name is the one Fowler now prefers.

How it works

  1. Put an interception point in front of the legacy system. This is usually a reverse proxy or API gateway for web traffic, or a message router for events. At first it forwards everything to the old system.
  2. Pick one capability, with clear boundaries and few dependencies, and build it in the new system.
  3. Sync the data it needs. Change data capture can stream the legacy database into the new service while the old system keeps writing.
  4. Route traffic for that capability to the new code, often for a small share of users first, behind a feature flag.
  5. Retire the old code for that capability once the new path has run cleanly.
  6. Repeat until the legacy system has nothing left to do.

Example: moving invoicing off a legacy ERP

A distributor runs a 15-year-old PHP ERP. Invoicing is slow and breaks with every GST rule change, so it goes first.

In week 0, the proxy sends everything to the legacy app:

location / { proxy_pass http://legacy_erp; }

In week 6, invoicing moves to the new service:

location /invoices/ { proxy_pass http://invoice_service; }
location /api/invoices/ { proxy_pass http://invoice_service; }
location / { proxy_pass http://legacy_erp; }

For three weeks the new invoice service runs in parallel. It generates each invoice from the same order data, and a nightly job compares totals and tax lines with the legacy output. With no differences in those three weeks, the new service becomes the system of record and the legacy invoicing screens are deleted. Order entry and stock follow in later slices.

When it fits, and when it doesn't

It fits large systems the business can't pause, and systems with traffic you can intercept, such as HTTP, queues or file drops. It is the standard route from a monolith to microservices, or to a modular monolith.

It struggles when you can't intercept calls, for example a desktop client that talks straight to the database. It is also more work than a rewrite for a small app. Every slice needs transitional code that you will later delete, and that overhead is part of the price.

Common mistakes

  • Never finishing. If old code isn't removed, you run two systems indefinitely.
  • Letting both systems write the same records.
  • Starting with the hardest, most connected module.

Our guide to modernising legacy software without a rewrite covers mapping, data and release steps in more detail.

Any idea in mind? Let's make it real.

Tell us what you're building. You'll hear back from an engineer, not a sales team, usually within one working day.

Book a 30-min call