What is the strangler fig pattern and when should you use it?

The strangler fig pattern is a migration strategy where you build new functionality alongside an existing system, gradually route traffic to it, and retire the old code in slices rather than all at once. It eliminates the risk of a 'big bang' rewrite by keeping the legacy system live until each piece is replaced and verified. Use it when you need to modernize a monolith or legacy platform without halting the business.

Where the name comes from

The strangler fig is a tree that grows around a host, eventually replacing it entirely while the host continues to stand. Martin Fowler applied the metaphor to software in 2004: a new system wraps and incrementally supplants an old one, with both running in parallel during the transition.

How the pattern works

  1. Identify a seam. Pick a discrete capability — a pricing engine, an authentication flow, a reporting module — that can be extracted without breaking everything else.
  2. Build the replacement. Develop the new service or module independently, in modern infrastructure, with its own data store if needed.
  3. Route traffic. Place a façade (a reverse proxy, API gateway, or feature flag) in front of both systems. Send a fraction of requests to the new service, verify correctness, then shift more traffic over.
  4. Retire the old slice. Once the new service handles 100% of that capability, delete the legacy code. Repeat for the next seam.

When to use it

  • Your legacy monolith is too risky to rewrite all at once — it handles real revenue, real users, or regulated data.
  • The team lacks full knowledge of the existing system (common with decade-old codebases).
  • Business continuity requirements mean you cannot tolerate a maintenance window longer than hours, not months.
  • You want to prove value early — each extracted slice ships to production and delivers measurable improvement.

When it may not be the right fit

  • Deeply tangled data models. If every module shares one giant relational schema with hundreds of joins, isolating seams is expensive before you can even start strangling.
  • Very small systems. A simple CRUD app may be faster to rewrite cleanly over a sprint or two than to orchestrate a multi-month strangler migration.
  • Near-end-of-life systems. If the system will be decommissioned anyway, the routing infrastructure adds cost without long-term benefit.

Key implementation risks

RiskMitigation
Data synchronization between old and newUse event streaming or dual-writes during transition; reconcile regularly
Façade becomes a single point of failureKeep the façade thin and stateless; load-balance it independently
Migration stalls mid-wayTime-box each slice; track retirement of legacy code as a first-class deliverable
Team context-switching costAssign dedicated squads per slice where headcount allows

Practical starting point

Most successful migrations start with a low-risk, high-pain module — often something like authentication, notifications, or a reporting pipeline — to build team confidence before tackling the core domain.

CodeNicely has used this approach when helping clients modernize legacy platforms, including re-architecting monolithic fintech and logistics systems into service-oriented backends while keeping production traffic live throughout. If you're scoping a legacy modernization, the strangler fig pattern is usually worth evaluating before committing to a full rewrite.

Related questions

What is the difference between the strangler fig pattern and a full rewrite?

A full rewrite replaces the entire system at once, which carries high risk because the new system only goes live after months or years of parallel work. The strangler fig pattern replaces the system in small, production-verified slices, so value is delivered continuously and rollback scope is narrow if something goes wrong.

What is a façade in the context of the strangler fig pattern?

A façade is a routing layer — typically a reverse proxy or API gateway — that sits in front of both the old and new systems. It intercepts incoming requests and directs each one to the appropriate system based on feature flags, URL paths, or traffic-splitting rules, allowing a gradual shift without clients noticing.

How long does a strangler fig migration typically take?

Duration depends heavily on the size of the legacy system, the number of seams you can isolate, and team capacity. Small systems may migrate in a few months; large enterprise platforms can take one to three years. Each slice should ship to production independently, so business value accrues throughout rather than only at the end.

Can the strangler fig pattern work for database migrations too?

Yes, but database migrations are the hardest part. Common approaches include dual-writes (writing to both old and new stores simultaneously), change data capture (CDC) to stream changes from the legacy database, and gradual read migration once the new store is confirmed consistent. Schema coupling is usually the main constraint that slows the overall migration.

Want a direct answer for your project?

CodeNicely builds AI products, MVPs, and custom software for founders and teams worldwide. Tell us what you're building.

Talk to our team