Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

Explain the strangler fig approach for replacing a legacy system and why it is usually safer than a full rewrite.

The strangler fig approach replaces a legacy system piece by piece: new functionality is built beside the old system, and a routing layer, such as a proxy, a gateway or code inside the old system, sends each request to either the old or the new code. Functions move one at a time, each released and verified on its own, until the old system has shrunk to nothing and can be switched off. It is safer than a full rewrite because every step is small, delivers value and can be rolled back.

Why this question is asked

Almost every developer meets a legacy system that everyone wants to replace. The tempting plan is a full rewrite: build the new system from scratch and switch over on one big day. Interviewers ask about the strangler fig because it is the standard answer to why that plan so often fails, and because understanding it shows a candidate thinks about risk, not only about code. In this answer, we will see where the name comes from, how the routing layer works, how a function moves from old to new, how the old system shrinks, and why this is safer than a rewrite.

1Where the Name Comes From

A strangler fig is a tree that starts as a seed on the branch of a host tree. It sends roots down around the host, grows slowly over many years, and eventually stands on its own while the host tree inside it dies away. Martin Fowler used this image to describe a way of replacing software: the new system grows around the old one, taking over its work bit by bit, until the old one is no longer needed.

The key idea is that both systems run at the same time for a long period. Users keep using one product, and behind the scenes some of their requests are served by new code and some by old code.

2The Routing Layer That Makes It Work

For both systems to serve one product, something must decide where each request goes. That is the routing layer. It can be a reverse proxy such as NGINX, an API gateway such as Spring Cloud Gateway, or, when the old system has no clean entry point, code inside the old system that calls the new service for certain operations.

At the start the router sends everything to the old system, so nothing changes for users. Then, for each function we move, we add a rule: requests for that function go to the new service. Because the rule lives in one place, we can turn it on for a few users, watch the results, and turn it off again in seconds if something is wrong.

Step throughOne product, two systems behind a router
UserRouterNew serviceLegacy system
GET /orders/42/tracking
tracking has moved: forward
tracking response
200 OK
POST /orders
ordering not moved yet: forward
order created
201 Created

8 messages in order. Play them, or step through them one at a time.

The user sees one system; the router decides, per function, which code answers.

3Moving One Function at a Time

We choose a function that is reasonably separate, such as order tracking or customer notifications. We build it in the new system, including the data it needs, often fed from the old database through events or change data capture, a technique that streams every row change from a database's log. We test it, then switch the route for a small share of users, compare its answers with the old system's, and increase the share as confidence grows.

Each move is a normal release with its own testing and rollback. Notice that the old code for that function is not deleted at once. It stays in place, unused, until the new path has been stable for a while; then it is removed, which is what actually shrinks the old system.

YAML
# Spring Cloud Gateway routes: only tracking has moved so far
spring:
cloud:
gateway:
routes:
- id: tracking-new
uri: http://tracking-service
predicates:
- Path=/orders/*/tracking # moved function -> new service
- id: legacy-everything-else
uri: http://legacy-orders
predicates:
- Path=/** # all other requests -> legacy

The route order matters: the more specific rule comes first, and the catch-all route to the legacy system is last. Moving the next function is one more route above the catch-all. Check the property names for your Spring Cloud Gateway version, since recent releases reorganised them.

4Watching the Old System Shrink

Over months or years, more routes point to new services and the old system handles less and less. We measure this, for example as the share of requests or business functions served by new code, because it shows progress and keeps the effort funded. When the last function has moved and its data has been migrated or archived, the catch-all route is removed and the old system is switched off.

Progress of a strangler migration
StageServed by new codeLegacy still runs
Router added0 percenteverything
Tracking moved15 percentorders, billing, returns
Returns and notifications moved45 percentorders, billing
Orders moved85 percentbilling
Billing moved, legacy off100 percentnothing

5Why It Is Safer Than a Full Rewrite

A full rewrite has to recreate everything the old system does, including rules nobody wrote down, before it can go live. For a large system that takes years, during which the business gets no new value from the project and the old system keeps changing, so the target moves. The cut-over day then carries all the risk at once: if anything is wrong, everything is wrong.

The strangler fig turns that one big bet into many small ones. Each step is small enough to understand and test, it delivers value as soon as it ships, such as a faster tracking page, and it can be rolled back by changing a route. Unknown rules are discovered one function at a time, while the old system is still there to compare against. The cost is that we run two systems for a long time and need discipline to finish, which is the trade-off to plan for.

6Follow-up questions

What are the downsides of the strangler fig approach?

Running two systems costs money and attention for the whole migration, data often has to be kept in sync between them, and the routing layer becomes a critical component. The biggest risk is stalling: the easy parts move, the hard parts remain, and the company ends up operating both systems indefinitely. A clear plan and a retirement date reduce that risk.

How do you handle data shared by old and new code?

Usually one side owns each piece of data at a time. While the old system owns it, the new service reads a copy fed by events or change data capture. When a function moves, ownership moves with it, and if the old system still needs the data, the flow is reversed. Writing the same data from both sides at once should be avoided.

Can you use the strangler fig inside one code base?

Yes. The same idea works inside a monolith: put an interface in front of an old module, write the new implementation behind it, and switch callers with a feature flag, one call site or one use case at a time. This is sometimes called branch by abstraction.

7Conclusion

In this answer, we saw how the strangler fig approach replaces a legacy system gradually. New functionality is built beside the old system, a routing layer such as a proxy, a gateway or code in the old system sends each request to old or new code, and functions move one at a time with their own release and verification. The old system shrinks until it can be removed, and the risk stays low because each step is small, delivers value and can be rolled back.

What to say in the interviewAbout 90 seconds aloud

Open with

The strangler fig approach replaces a legacy system gradually instead of all at once. The name comes from a tree that grows around a host tree until it stands on its own.

Then, if they want more

In software, we put a routing layer in front of the old system, which can be a reverse proxy, an API gateway like Spring Cloud Gateway, or code inside the old system. At first it sends everything to the old system.

Then we build one function in a new service, for example order tracking, with the data it needs, and add a route so tracking requests go to the new code, first for a small share of users while we compare results.

Each move is a separate release with its own testing and rollback, and once it is stable we delete the old code for that function. Over time the old system handles less and less until we can switch it off.

It is safer than a full rewrite because a rewrite has to reproduce everything, including undocumented rules, before going live, delivers nothing for years, and puts all the risk on one cut-over day. With the strangler fig every step is small, gives value as soon as it ships, and can be rolled back by changing a route.

The cost is running two systems for a while, so you need a plan to actually finish.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain the strangler fig approach for replacing a legacy system and why it is usually...": https://scrivio-interview-library.netlify.app/architecture/modernization/6e09c39f46/