The Strangler Fig Pattern: Gradually Refactoring Monoliths into Microservices
The Monolith's Dilemma
The Strangler Fig Pattern 🌳 helps you safely refactor a monolithic application by gradually replacing old functionality with new microservices, routing traffic through a facade.
🎯 System Scenario & Requirements
System Goal
The Strangler Fig Pattern 🌳 helps you safely refactor a monolithic application by gradually replacing old functionality with new microservices, routing traffic through a facade.
Actors & Components
- Legacy System
- New Microservices
- Client
- Strangler Facade
- Legacy Monolith
- New Service A (e.g., Orders)
- New Service B (e.g., Inventory)
Functional Requirements
- TLDR: The Strangler Fig Pattern 🌳 helps you safely refactor a monolithic application by gradually replacing old functionality with new microservices, routing traffic through a facade.
- This reduces the risk of a "big bang" rewrite, allowing for continuous delivery and evolving bounded contexts.
- You're likely familiar with the challenge: an aging, tightly coupled monolithic application that has become a bottleneck for new feature development, scalability, and independent team work.
Constraints & Assumptions
- Constraints are derived from the rebuilt scenario stages.
⚡ Execution Stages & Decision Trace
Stage 1 — Growing New Contexts with the Strangler Fig
The Strangler Fig Pattern, inspired by the growth of a strangler fig tree around a host tree, provides a solution.
Instead of rewriting everything at once, you introduce a new facade (often an API Gateway or a reverse proxy) in front of the existing monolith.
Deep Dive
Scenario context
The Strangler Fig Pattern 🌳 helps you safely refactor a monolithic application by gradually replacing old functionality with new microservices, routing traffic through a facade. This reduces the risk of a "big bang" rewrite, allowing for continuous delivery and evolving bounded contexts.
You're likely familiar with the challenge: an aging, tightly coupled monolithic application that has become a bottleneck for new…
This walkthrough focuses on The Monolith's Dilemma.
Before making a design choice, clarify:
- You're likely familiar with the challenge: an aging, tightly coupled monolithic application that has become a bottleneck for new feature development, scalability, and independent team work.
- The desire to move to a microservices architecture is strong, but the thought of a complete "big bang" rewrite is terrifying due to its high risk, cost, and potential for failure.
- How do you refactor such a complex system into smaller, more manageable microservices without halting business operations or introducing catastrophic bugs?
Concepts in play: design-patterns-gof, api-gateway, tree-data-structures, load-balancing
Stage 1 — Growing New Contexts with the Strangler Fig
- The Strangler Fig Pattern, inspired by the growth of a strangler fig tree around a host tree, provides a solution.
- Instead of rewriting everything at once, you introduce a new facade (often an API Gateway or a reverse proxy) in front of the existing monolith.
- As you identify new features or areas suitable for extraction into their own microservices (i.e., new bounded contexts), you build these new services independently.
- The facade then intelligently routes requests: new functionality goes to the new microservices, while existing, un-refactored functionality continues to be served by the old monolith.
Observable outcome: The facade then intelligently routes requests: new functionality goes to the new microservices, while existing, un-refactored functionality continues to be served by the old monolith.
Stage 2 — Visualizing the Gradual Transition
- { "version": 1, "title": "Strangler Fig Pattern: Gradual Decomposition", "description": "Client requests are routed through a Strangler Facade, which directs traffic to either new microservices or the legacy monolith, a…
Observable outcome: { "version": 1, "title": "Strangler Fig Pattern: Gradual Decomposition", "description": "Client requests are routed through a Strangler Facade, which directs traffic to either new microservices or the legacy monolith, a…
Stage 3 — Benefits and Considerations
- The Strangler Fig Pattern offers significant advantages: reduced risk, continuous delivery, and the ability to learn and adapt your microservice boundaries over time.
- It allows you to tackle complexity in smaller, manageable chunks.
- However, it introduces an overhead of maintaining both the old and new systems concurrently, and the Strangler Facade itself can become a point of complexity if not managed well.
- Careful planning of domain boundaries (bounded contexts) and robust routing logic are key to a successful transition.
Observable outcome: Careful planning of domain boundaries (bounded contexts) and robust routing logic are key to a successful transition.
End-to-end outcome
You're likely familiar with the challenge: an aging, tightly coupled monolithic application that has become a bottleneck for new feature development, scalability, and independent team work.
Alternatives considered
The source focuses on one primary design. A second architecture is not compared, so no alternative is invented here.
Failure and degraded modes
The source does not isolate a separate failure mode. Limits that matter for the scenario are called out in the stage decisions above.
Key learnings
- The Strangler Fig Pattern, inspired by the growth of a strangler fig tree around a host tree, provides a solution.
- { "version": 1, "title": "Strangler Fig Pattern: Gradual Decomposition", "description": "Client requests are routed through a Strangler Facade, which directs traffic to either new microservices or the legacy monolith, a…
- The Strangler Fig Pattern offers significant advantages: reduced risk, continuous delivery, and the ability to learn and adapt your microservice boundaries over time.
