Practice this topic in a realistic system design interview
Modernization almost always happens while the old system is still serving real users. You usually cannot switch it off and start over, and a full rewrite puts years of work and a huge amount of risk into one big launch.
The Strangler Fig pattern takes a safer path. The new system grows around the old one and takes over one piece at a time, while a routing layer decides which system handles each request. Eventually, the old system has nothing left to do and can be shut down.
This chapter covers what the Strangler Fig pattern is, how it helps teams replace a legacy system gradually instead of all at once, how traffic and data move from the old system to the new one, and the challenges that come with a long migration.
Suppose a company runs an e-commerce platform built as one large monolith. It is ten years old and handles products, carts, orders, payments, and user accounts in a single codebase.
Over time, the system has become difficult to change. Deployments are slow and risky, and a bug in one area can affect the entire site. So the team decides to move to a new architecture.
One option is a complete rewrite. The team builds the new system from scratch and then switches over on a single day. This is often called a big-bang rewrite, and it comes with serious risks.
This is why large rewrites are often much harder than they first appear.
The Strangler Fig pattern takes a different approach. Martin Fowler named it in 2004 after strangler fig trees he saw in the rainforests of Queensland, Australia.
A strangler fig begins as a seed high in the branches of another tree. It sends roots down toward the ground and gradually grows around the host. Over time, the fig becomes larger while the original tree declines. Eventually, the host dies and the fig stands on its own in roughly the same place.
There is no point where the old tree is suddenly removed and replaced.
That is the idea behind the pattern. The new system gradually grows around the old one, taking over one piece at a time until the legacy system is no longer needed.