Rather than define the strangler fig pattern in the abstract, let us follow one migration from the first week to the last. The company is made up: a Coimbatore distributor of industrial fasteners with an order-management application written in Java about fifteen years ago. It runs on two servers, has few automated tests, and the developers who wrote it have left. The business wants a customer web portal, which the old system cannot support. A full rewrite was estimated at eighteen months, with nothing usable until the end. That is the risk the pattern exists to avoid.

Martin Fowler named the idea after strangler figs, vines that grow around a host tree and eventually replace it. In software terms: build the new system around the edges of the old one, move functionality across piece by piece, and switch the old parts off only when nothing uses them.

Step 1: put a front door in front of everything

Today, users and partner systems call the legacy application directly. The first move changes nothing visible. The team places a thin routing layer, a reverse proxy or API gateway, in front of the legacy system. Every request passes through it, and initially all of them are forwarded to the old application untouched.

This is a deliberate, boring first release. It proves the proxy works, gives the team logs of real traffic (which paths are used, how often, by whom), and creates the seam where later routing decisions will happen. If the proxy causes trouble, it can be removed in minutes.

Step 2: choose the first slice carefully

The traffic logs show that “check order status” is the most requested operation, perhaps 60% of calls, and it only reads data. That is an ideal first slice: high visibility, low risk, because a read-only feature cannot corrupt anything. The portal needs it anyway.

A poor first choice would be “create invoice”, which is tangled with tax, stock and accounting rules. Start where the dependencies are fewest and the value is clearest. Resist the temptation to begin with the hardest part to “get it out of the way”; you will spend months and have nothing running.

Step 3: build the new slice, and deal with the data

The new order-status service needs order data, and the data still lives in the legacy database. There are three common options, each with a cost.

  • Read directly from the legacy database. Quickest, and acceptable for a short time, but it ties the new service to the old schema. Use a read-only account and wrap the access in one small module.
  • Replicate the data. Copy changes from the legacy database into the new service’s own store, for example by reading its change log or a periodic extract. The new service owns a copy and may lag by seconds or minutes.
  • Call the legacy system through an adapter. A translation layer converts the old system’s responses into the new model, so odd field names and status codes do not spread. This is the anti-corruption layer idea.

The team picks replication with a small adapter, accepting a lag of about a minute, which the business confirms is fine for status checks.

Step 4: shift traffic gradually

Now the proxy earns its place. First, it sends a copy of each status request to both the old and new implementations and compares answers, returning only the old one to the user. The differences reveal bugs and undocumented behaviour, such as a legacy rule that hides cancelled orders older than ninety days. These surprises are the real value of this phase; no specification would have listed them.

When the mismatch rate is acceptable, route 5% of real traffic to the new service, then 25%, then 100%, watching errors and response times at each step. At any point, flipping a routing rule sends everyone back to the old path. Rollback costs seconds, not a restore from backup.

Step 5: repeat, then delete

Next slices follow the same loop: order history, then customer profiles, then order creation, which is harder because it must write. Writes bring the genuine difficulty. During the transition, which system is the source of truth for an order? Pick one at a time, and avoid having both write to the same data. Typically ownership of a whole capability is switched at once, with the old code path frozen and later removed.

Eventually the proxy forwards almost nothing to the legacy application. Check the logs to confirm: a month of zero traffic to an old feature is a better proof than anybody’s opinion that “nobody uses that”. Then switch off the old module, remove its code, and keep the old database in read-only archive for as long as audit rules require. In India, record retention duties under the Companies Act and tax law may govern how long, so confirm with your finance and compliance people.

When this approach struggles

The pattern works best when requests can be routed by capability, such as web or API traffic. It is harder for batch jobs, shared database logic such as stored procedures that hold business rules, and thick desktop clients. It also has a real cost: for a long time you run two systems, with duplicated infrastructure, and a team can be tempted to stop at 70% and leave both alive indefinitely. Treat the final deletion as part of the plan, with an owner and a date, or you will have added a system rather than replaced one.

Even so, each step above delivers something the business can see within weeks, and each can be reversed. That is why the approach is usually preferred over the eighteen-month rewrite: it turns one huge bet into many small ones.

Figures and names in the examples are illustrative.

Leave a Reply

Trending