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
| Part | Question |
|---|---|
| Boundary | Which specific fragment of behavior is being replaced? |
| Router | Which stable condition selects the legacy or new path? |
| Coexistence | How do the paths operate together without duplicate side effects? |
| Evidence | How can we see the path, output, error, and migration state? |
| Rollback | How can we disable the new path and return without data loss? |
| Exit | When can the legacy fragment be removed? |
Replacement stages
- Record current behavior and the seam for one fragment.
- Add the new implementation behind the existing contract without expanding scope.
- Define routing or a feature boundary with explicit default behavior.
- Check the old and new paths on the same representative inputs.
- Observe discrepancies, error rate, and side effects before expanding coverage.
- Increase the slice gradually only after a risk gate.
- 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
# 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 risksCanonical lesson source · JavaRush
Open JavaRush material