SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
  • Service Discovery
  • API Gateway Pattern
  • Backend for Frontend (BFF)
  • Sidecar Pattern
  • Circuit Breaker
  • Bulkhead
  • Strangler Fig
  • Service Mesh
  • Database per Service
  • Timeouts and Deadlines
  • API Composition
  • Anti-Corruption Layer
  • Ambassador Pattern
  • Idempotent Consumer and Inbox Pattern
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Architecture/Microservices Patterns

Strangler Fig

Replace an old system piece by piece, until nothing of the old one remains.

⏱ 12 min readIntermediateInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

The Strangler Fig pattern is a safe way to replace an old system. You build the new system piece by piece around the old one, send more and more traffic to the new pieces, and switch the old one off when nothing uses it any more.

  • A facade (a proxy or API gateway) sits in front and decides, for each request, whether the old or the new code answers it.
  • You move one small slice at a time (for example search, then reviews, then checkout). Each slice goes live on its own.
  • If a new slice has a bug, you route back to the old one. There is no big, risky switch day.

02Concept: What is it?

The name comes from a real plant. A strangler fig seed lands on a tree and grows roots down around its trunk. Over many years the fig grows bigger and stronger, until it can stand on its own. The old tree inside slowly dies and is gone. The fig took its place, and the forest never had an empty spot.

In software, a big-bang rewrite means building a whole new system in secret for a year or two, then switching on a single day. This is risky: the old system keeps changing while you build, the new one is never tested by real users until the last moment, and if it fails you have nowhere to go back to. Many such rewrites are late, over budget, or cancelled.

The Strangler Fig avoids this. First you put a facade in front of the old system. At the start it sends everything to the old code, so nothing changes for users. Then you build one feature in the new system, test it, and tell the facade to send that feature's requests to the new code. You repeat this until the old system receives no traffic.

The facade decides who answers
πŸ‘₯Users
→↓
🧭Facadeproxy / gateway
↔
🏚️Old systemshrinks over time
🌱New systemgrows over time
Users only know the facade. Behind it, requests slowly move from the old system to the new one.
🧠Small steps, always working
At every moment the system as a whole works. Each step is small, can be released alone, and can be undone by changing one routing rule.

03Real-Life Example

🍡Renovating a Shop That Stays Open
A family runs a busy shop in an old building. They want a modern building, but closing for two years would lose all their customers. So they build the new shop next door, one department at a time. First the toys move over. A sign at the front door says "Toys: go next door". If the new toy department has a problem, they just change the sign back. Later the books move, then the clothes. One day the old building is empty, and they close it. Customers never saw a closed shop.
The shop move
Strangler Fig
The old building
The legacy system
The new building next door
The new system
The sign at the front door
The facade (proxy or gateway routing rules)
Moving one department at a time
Migrating one feature (slice) at a time
Changing the sign back
Rolling back by changing a route
Staying open during the move
No downtime for users
Closing the empty old building
Retiring the legacy system
Three stages of the same system
Start
Old systemall requests
New system
Middle
Old systemmost features
New systemsome features
End
Old systemswitch it off
New systemall requests

04Why Do We Need It?

πŸ›‘οΈLow risk
Each step is small. A bug affects one slice, not the whole product.
↩️Easy rollback
Change one routing rule and the old code answers again.
πŸ’°Value early
The first new slice is useful in weeks, not after a two-year project.
πŸ“šLearn on the way
You find hidden rules of the old system one slice at a time, instead of all at once.
πŸ•No big freeze
The old system can still get fixes while the migration goes on.
😌Calm teams
No launch-night panic. The migration can pause and restart when priorities change.
Do not rewrite the whole thing and hope. Replace it a slice at a time, behind a facade, so users never notice and you can always go back.

05Where Do We Use It?

🧱Monolith to microservices
The most common use: pull one feature out of a big monolith into its own service, then the next.
☁️Moving to the cloud
Move parts of an on-premises system to cloud services step by step.
πŸ§“Old technology
Leave an old language, framework or mainframe (for example old COBOL or an out-of-date web framework).
πŸ—„οΈDatabase migration
Move one table or one feature at a time from an old database to a new one.
πŸ”ŒReplacing a vendor
Swap a third-party product for your own, or for another vendor, one capability at a time.
🎨Web front end
Move page by page from an old UI to a new one behind the same web address.

06Types / Parts / How It Works

The three steps (often called transform, coexist, eliminate)

The migration loop
  1. 🧭
    1. Put a facade in front
    All traffic still goes to the old system
  2. 🌱
    2. Build one slice
    Rebuild one feature in the new system
  3. πŸ”€
    3. Route that slice
    Send its requests to the new code
  4. 🧹
    4. Remove the old slice
    Delete the old code when you are confident
Repeat the loop for every slice until the old system is empty.

Ways to put the facade in front

Where the routing livesHow it worksGood and bad
Reverse proxy or API gatewayRoutes by URL path, for example /search goes to new, the rest to oldMost common and simple. Needs a clean URL for each slice.
Load balancer rulesRules on host name, path or header choose the targetCheap to add. Limited logic.
Feature flags in the appCode checks a flag and calls the old or the new moduleFine-grained, can target users. The routing logic lives in code.
Event interceptionNew code listens to events or changes (for example a change feed from the old database)Good when there is no clean URL boundary. More moving parts.
UI compositionThe page is built from pieces, some served by old and some by newSmooth for user interfaces. Needs careful styling and sessions.

How to cut slices

Way to sliceExampleNote
By feature or URL/search, /reviews, /checkoutThe easiest and most common
By business areaOrders, Customers, InventoryMatches teams and data owners
By user groupNew customers on new code, old customers on oldGood for a safe canary
By read, then writeMove reads first, writes laterReads are low risk and easy to compare
By region or tenantOne country or one client at a timeLimits the damage of a bug
VisualizerStrangle the old system: slice by slice or all at onceClick the arrows to move one feature at a time to the new system. Send traffic and see which slices break. Then try the big-bang mode and compare how hard it is to recover.
How do you replace the old system?
Users
🧭 Facade (routes each request)
🏚️ Old system
🌱 New system
πŸ”Ž Search (20%)
-
πŸ“š Catalog (15%)
-
⭐ Reviews (8%)
-
πŸ‘€ Accounts (10%)
-
πŸ›’ Cart (15%)
-
πŸ“¦ Orders (10%)
-
🧾 Checkout (12%)
-
πŸ’³ Payments (10%)
-
On the new system
0 / 8
features moved
Traffic on new code
0%
share of requests
Failing requests
-
after Send traffic
Old system
100%
still serves requests
Everything still runs on the old system. The facade is already in front, but it sends all requests to the old code. Click a feature to move just that slice to the new system.

A simplified model. Two slices (Cart and Payments) have a hidden bug in their new version. In a real project you find such bugs with tests, shadow traffic and small canary shares before moving a feature fully.

07How to Use It / Steps / Implementation

Running a Strangler Fig migration

  1. 1
    Find the seams
    Look for natural borders in the old system: a URL path, a module, a table, a message. These are places where you can cut a slice with little change to the rest.
  2. 2
    Put the facade in front first
    Add a proxy or gateway that forwards everything to the old system. Release it, and check that nothing changed. This is your control panel.
  3. 3
    Pick a small, low-risk first slice
    Start with something read-only or easy to compare (search, a catalog, reviews). Save checkout and payments for later, when the team has practice.
  4. 4
    Build it and test it
    Build the new slice. Compare it with the old one using the same inputs. Shadow traffic (send a copy of real requests to the new code, but ignore its answers) is a great test.
  5. 5
    Roll out slowly
    Route 1% of traffic, then 10%, then 50%, then 100% (a canary release). Watch errors and latency at each step.
  6. 6
    Handle the data
    Decide who owns the data. Either the new slice reads the old database for a while, or you copy data in both directions (sync) until the move is complete.
  7. 7
    Delete the old code
    When the slice runs at 100% and is stable, remove the old code. If you never delete, you get two systems forever.
  8. 8
    Repeat and finally retire
    Continue slice by slice. When the old system receives no traffic, switch it off and remove the facade rules.
πŸ’‘Build an anti-corruption layer
The old system may use odd names and strange data shapes. Put a small translation layer between old and new, so the new code stays clean and does not copy the old design.
⚠️Do not stop half way
The scary result is a system stuck in the middle: two codebases, two databases, and a facade nobody wants to own. Plan the end, give each slice a deadline, and delete as you go.

08Key Terms to Know

TermMeaning in easy words
Legacy systemThe old system you want to replace
FacadeA layer in front (proxy or gateway) that routes each request to the old or new code
SliceOne small, separate piece of function that is moved on its own
SeamA natural border in the old system where it can be cut with little change
Big-bang rewriteReplacing the whole system in one switch after a long hidden build
Canary releaseSend a small share of real traffic to new code first, then grow it
Shadow trafficA copy of real requests sent to the new code, with answers ignored, to test it
Anti-corruption layerA translation layer that stops the old design leaking into the new code
Feature flagA switch in code or config that turns a feature on or off, or picks old or new
Dual write / data syncKeeping old and new data stores equal while both exist
RollbackSending traffic back to the old code after a problem

09Pros, Cons and Trade-offs

βœ… Pros
  • Small steps with low risk
  • Easy rollback by changing a route
  • Users see no downtime
  • Value arrives early and often
  • The old system keeps working during the move
⚠️ Cons
  • Takes a long time overall
  • Two systems to run and pay for during the move
  • Data syncing between old and new is hard
  • The facade is an extra hop and a new key component
  • Easy to stall half way

Trade-offs

ChoiceWe gainWe lose
Strangler FigSafety, early value, rollbackA longer project and the cost of running both systems
Big-bang rewriteA clean start and a short final cutoverHuge risk, late feedback, no way back
Small slicesVery low risk per stepMore steps and more routing rules to manage
Large slicesFewer stepsEach step is harder to test and roll back
Shared database during the moveSimple at first, no data copyingThe new service stays tied to the old schema
Separate database per sliceA clean, independent designNeeds data sync and care about consistency

10Common Problems and Mistakes

Common mistakes

  1. Starting with the hardest part. Beginning with payments or checkout means the team learns on the riskiest slice. Start small.
  2. Never deleting old code. The old and new paths both stay, and the project turns into two systems forever.
  3. Forgetting the data. Code moves easily. Data is the hard part, especially when old and new both write to it.
  4. Making the facade smart. A facade full of business logic becomes a new monolith. Keep it to routing.
  5. Copying the old design. Rebuilding every strange rule makes the new system as messy as the old. Use an anti-corruption layer.
  6. No measurements. Without error and latency checks per slice, you cannot know whether the new code is better.
  7. No end date. Without a plan to retire the old system, the work slowly stops being a priority.

Things to watch

πŸ”Data in two places
If both systems write the same data, they can disagree. Choose one owner for each piece of data.
πŸ•ΈοΈHidden coupling
The old code may call itself in ways nobody documented. Slices can break things far away.
🐌Extra latency
A request may go through the facade and then cross to the old system. Measure it.
πŸͺ’Facade as a single point of failure
If the facade is down, everything is down. Run several copies of it.

11Real-World Examples

🌳The name
Martin Fowler popularised the name after seeing strangler figs in Australian rainforests. The idea is now standard advice for rewrites.
☁️AWS and Azure guides
Both clouds publish Strangler Fig guidance for moving a monolith to services, usually with a gateway or proxy as the facade.
πŸ“¦Large online shops
Well-known retailers moved from big monoliths to services slice by slice, often starting with read-only parts such as search and product pages.
🏦Banks and insurers
Old mainframe systems are often wrapped by a facade, then replaced one product or feature at a time.
🌐Website rewrites
A reverse proxy sends some URLs to the new site and the rest to the old one, until the old site is empty.
πŸ›οΈGovernment systems
Public services use it to modernise without any gap in service for citizens.
πŸ“Note
Company stories are often shared in talks and blog posts, and details differ from source to source. Treat them as examples of the idea rather than exact recipes.
Mini case: moving search out of a monolith
πŸ‘₯Users
→↓
🧭API gateway
→↓/search
πŸ”ŽSearch servicenew
↓everything else
🏚️Monolithold
Facade New code Old code
The gateway routes by path. Only /search goes to the new service.

12Related Topics to Read Next

Monolithic Architecture→

The kind of old system that is most often strangled.

Microservices→

The usual target when a monolith is split into pieces.

API Gateway Pattern→

A common choice for the facade that routes old and new.

Proxy vs Reverse Proxy→

A reverse proxy can be the facade in front of both systems.

What are Load Balancers?β†’

Routing rules and traffic shares are close to what a load balancer does.

Replication→

Copying data between old and new databases uses similar ideas.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • βœ”What: replace a legacy system one slice at a time behind a facade.
  • βœ”Facade: a proxy or gateway that routes requests to old or new. Routing only, no business logic.
  • βœ”Steps: facade first, build a slice, route it, delete the old slice, repeat.
  • βœ”First slice: small, low risk, read-only, clear border.
  • βœ”Roll out: shadow traffic, then canary 1% to 100%, with metrics at each step.
  • βœ”Hardest part: the data. Give each piece one owner and plan syncing.
  • βœ”Danger: stopping half way. Set deadlines, delete old code, retire the old system.
  • βœ”One line: β€œGrow the new system around the old one until the old one is not needed.”
← Previous
Bulkhead
Next β†’
Service Mesh