patterntypescriptTip
Strangler Fig: incrementally migrate a monolith without a big-bang rewrite
Viewed 0 times
strangler figmonolith migrationincrementalfacadefeature extractionrefactoringMartin Fowler
Problem
A legacy monolith is too risky to rewrite in one go. A full freeze-and-rewrite takes 12-18 months, during which new features cannot ship and the risk of failure is catastrophic.
Solution
Use the Strangler Fig pattern: route traffic through a facade (often the existing reverse proxy). Gradually extract features as new microservices. The facade routes requests for migrated features to the new service and everything else to the monolith. The monolith shrinks until it can be retired.
// facade/router.ts
router.use('/api/orders', isFeatureMigrated('orders')
? proxy({ target: ORDER_SERVICE_URL })
: proxy({ target: MONOLITH_URL })
);Why
Named after the strangler fig tree that grows around a host tree and eventually replaces it. Risk is distributed over many small deployments. Each extraction is independently testable and reversible.
Gotchas
- Data ownership must be resolved early — two systems writing to the same table is a recipe for corruption
- Keep the facade logic minimal — complex routing rules become an unmaintainable mess
- Use feature flags to control migration rollout and enable instant rollback
- The monolith's test suite is your safety net — keep it green throughout the migration
Context
Teams migrating a large existing monolith to microservices while maintaining continuous delivery
Revisions (0)
No revisions yet.