Strangler Fig is gradual replacement, not a big-bang rewrite

The Strangler Fig pattern lets a new fragment gradually take over part of the behavior around a legacy system. The old and new paths coexist for a time, and each step has an explicit boundary, routing rule, ownership, verification, and rollback.

The pattern name does not justify a hidden migration. If there is no way to tell which path ran, or rollback leaves duplicate writes, this is not a controlled strangler slice.

Minimal strangler slice model

PartQuestion
BoundaryWhich specific fragment of behavior is being replaced?
RouterWhich stable condition selects the legacy or new path?
CoexistenceHow do the paths operate together without duplicate side effects?
EvidenceHow can we see the path, output, error, and migration state?
RollbackHow can we disable the new path and return without data loss?
ExitWhen can the legacy fragment be removed?

Replacement stages

  1. Record current behavior and the seam for one fragment.
  2. Add the new implementation behind the existing contract without expanding scope.
  3. Define routing or a feature boundary with explicit default behavior.
  4. Check the old and new paths on the same representative inputs.
  5. Observe discrepancies, error rate, and side effects before expanding coverage.
  6. Increase the slice gradually only after a risk gate.
  7. Remove legacy code only after exit criteria and a confirmed rollback window.

Coexistence dangers

  • two paths write the same resource or send two notifications;
  • the new path has different timezone, rounding, retry, or idempotency semantics;
  • the routing rule depends on an unverified flag or configuration precedence;
  • rollback switches code but does not restore already changed state;
  • the legacy path continues to receive traffic but no one observes it anymore.

Strangler slice record

Replacement document skeleton
# STRANGLER_SLICE.md

## Fragment and boundary
## Legacy path
## New path
## Routing rule
## Coexistence and side effects
## Verification evidence
## Rollback procedure
## Exit criteria
## Owner and open risks

Canonical lesson source · JavaRush

Open JavaRush material