Strangler Fig

Aplicación estranguladora

Escrito por Darjus Kazakevic · revisado el

Replace an old system while it keeps running and earning.

A big-bang rewrite stops shipping for a year or more, while the old system keeps changing. The strangler fig avoids that. You put an interception point (a proxy or gateway) in front of the old system. Then you move one capability at a time to the new one. Each move is small, reversible and tested by real traffic.

The name comes from a fig that grows around a host tree until the host is gone. Teams that finish do two things. They migrate whole capabilities, never layers. And they plan and fund the work of deleting the old code.

En esencia — Put a facade in front of the old system, move one capability at a time behind it, and delete each old part as soon as it is replaced.

Cuándo recurrir a él

Recurre a él cuando

  • The old system earns money and cannot stop for a rewrite
  • A rewrite would take longer than the business is willing to wait
  • You can intercept requests at a boundary, or can add one

Reconsidéralo cuando

  • The system is small enough to rewrite in a few weeks
  • It is being switched off, with nothing new to route to
  • Nobody will fund deleting the old system, only building the new one

The moving parts

The interception point (the facade)
The layer every request passes through, deployed before anything moves. Its first release sends all traffic to the old system. After that, moving one route is a config change, not a release.
The capability slice
The unit of migration: one thing the business recognises, such as order lookup, moved end to end with its routes, rules and data. Each slice ships on its own.
Data ownership
While both systems run, some data matters to both. For each slice, exactly one side owns the writes. The other side reads a synced view, an event feed or the owner's API.
Retirement
A slice is done when the old code is deleted, not when the new path serves traffic. Until then you pay for two implementations, and the rollback path quietly becomes permanent.

Rules for a migration that finishes

Ship the facade before you move anything
First deploy the interception point, sending all traffic to the old system, and prove it changes nothing. If that release is not boring, you have not found a clean seam yet.
Migrate capabilities, never layers
Moving “the data access layer first” takes months and gives users nothing. A vertical slice (routes, rules and storage together) ships value the day it lands and tests the new design.
Shadow-run, then switch by config
Run the new code beside the old on live traffic, return the old answer and log the differences. Then switch the route in config, so rollback is a config change, not a deploy.
Declare one writer per piece of data
Before a slice starts, name the side that owns writes; the other side reads. Two systems writing the same records with no owner drift apart, and a finance report finds it months later.

Errores habituales

  • The fig that never finishes: the dull last 10% (a batch job, one report) never moves, and both systems live on.
  • Migrating layers instead of capabilities, so months pass with nothing to ship.
  • Dual writes with no declared owner, drifting apart until an audit finds it.
  • Copying the legacy model into the new system through the facade, which an anti-corruption layer exists to prevent.