Strangler Fig Pattern

Updated June 8, 2026
M
Magic Magnets Team
8 min read

Have you ever tried to rewrite a massive legacy application from scratch? If so, you probably know it's a terrifying endeavor. The "Big Bang" rewrite, where you build the new system in secret for two years and switch over in one night, rarely works. It's risky, stressful, and usually ends in downtime.

Enter the Strangler Fig Pattern.

The Core Concept: A Simple Analogy

Imagine you live in an old, crumbling house, and you want to build a modern mansion on the same plot of land. Instead of demolishing your house and living in a tent for a year, you build the new mansion room by room, wrapping it around the old house.

Once the new kitchen is done, you start cooking there and board up the old one. Then you build the new bedroom, then the living room. Eventually, the new house completely surrounds the old one, and you can safely demolish whatever is left of the original structure. You never had to sleep in a tent!

In software engineering, the Strangler Fig Pattern is exactly this: incrementally migrating a legacy system by gradually replacing specific pieces of functionality with new applications and services.

algobase.dev
Phase 1: The router is inserted in front of the monolith. Billing requests are redirected to the new Billing Service. Everything else still goes to the monolith. Zero downtime, zero risk.
1 / 1

Phase 1: The router redirects billing traffic to a new service. Everything else still goes to the monolith. | Phase 2: More features are extracted. The monolith shrinks until it can be removed.

The strangler fig tree wraps around its host tree, eventually replacing it completely.

How the Strangler Fig Pattern Works

The pattern gets its name from a type of vine that seeds in the upper branches of a tree and gradually grows down to the soil, wrapping around the host tree and eventually "strangling" and replacing it.

Here is the typical step-by-step process:

  1. Identify a piece of functionality: Pick a specific, decoupled feature in your legacy monolith (e.g., the billing module).
  2. Build the new service: Create a modern microservice for this specific functionality.
  3. Insert an API Gateway or Router: Put a routing layer in front of your legacy system.
  4. Route traffic: Configure the router to send requests for the new feature to the new microservice, while all other requests continue going to the legacy monolith.
  5. Rinse and repeat: Pick the next feature, build it, and route traffic to it.

Over time, the legacy monolith shrinks until it disappears entirely.

Real-World Examples

Many of the tech giants we admire today didn't start with perfect microservices; they evolved from monoliths using this exact pattern.

Amazon

Back in the early 2000s, Amazon was a massive C++ and Perl monolith. They didn't rewrite Amazon.com overnight. They painstakingly extracted services like the "Buy" button, the tax calculator, and the inventory manager into separate services, routing traffic to them one by one.

Best Buy

When Best Buy wanted to modernize their e-commerce platform, they faced a giant legacy system that was slowing down development. They used the Strangler Fig Pattern to isolate features (like product details and user accounts) into independent microservices, seamlessly routing user traffic via an API Gateway without customers ever noticing a disruption.

When Should You Use It?

The Strangler Fig Pattern is ideal when:

  • You have a large, complex monolithic application that is hard to maintain.
  • You want to migrate to a new architecture (like microservices or serverless) without risking a "Big Bang" release.
  • You need to continue delivering new features while modernizing the platform.

[!TIP] Don't start with the most critical, complex part of your system. Pick a low-risk, loosely coupled feature for your first "strangled" service to test the waters and build confidence in your routing layer.

Summary

The Strangler Fig Pattern is the safest way to modernize legacy software. By putting a routing layer in front of your application and slowly chipping away at the monolith, replacing it piece by piece with modern services, you reduce risk, deliver value incrementally, and keep the system running the entire time.

Service Mesh

How helpful was this content?

Comments

0/2000

Sign in to join the discussion

Saved on this device only

Sign in to sync progress across devices