Intermediate LevelSoftware Engineering Principles
What is the Strangler Fig Pattern and how do you incrementally migrate monolithic legacy systems?
❓ Interview Prompt: Explain the Strangler Fig Pattern (Martin Fowler), incremental migration, API Gateway routing, and replacing legacy monoliths safely.
The Strangler Fig Pattern incrementally replaces a legacy monolithic application by replacing functional modules with modern microservices one by one until the monolith is retired:
Migration Steps:
1
Place an API Gateway / Reverse Proxy in front of the legacy monolith.
2
Build a new microservice for a single feature (e.g. Payment Service).
3
Update Gateway routing rules to direct '/payments' requests to the new service while keeping all other traffic directed to the monolith.
4
Repeat for all modules until the legacy monolith can be safely decommissioned!
Code Implementation Example
yaml
# NGINX Reverse Proxy implementing Strangler Fig routing
http {
upstream legacy_monolith { server monolith.internal:8080; }
upstream new_payment_service { server payments.internal:3000; }
server {
location /api/v1/payments { proxy_pass http://new_payment_service; }
location / { proxy_pass http://legacy_monolith; } # Default legacy traffic
}
}💡NGINX reverse proxy routing rules implementing the Strangler Fig pattern.
🎯 Interview Key Takeaway
Migrate legacy monoliths incrementally using the Strangler Fig pattern to eliminate big-bang rewrite risks.
#Strangler Fig#Legacy Migration#Architecture#Intermediate
Back to all Software Engineering Principles Questions→