API / Microservices Design Patterns Interview Questions
What is the Strangler Fig pattern and when should you use it to migrate a monolith?
The Strangler Fig pattern — coined by Martin Fowler after the strangler fig tree that gradually wraps and replaces its host — is an incremental migration strategy for moving functionality out of a monolith into microservices. Instead of a risky "big bang" rewrite, you build new services alongside the running monolith, route traffic to them one capability at a time, and eventually decommission the hollowed-out monolith.
The three-step migration cycle for each capability:
- Insert a facade — place a reverse proxy, API gateway, or routing layer in front of the monolith. All traffic flows through this facade, which initially passes everything unchanged to the monolith.
- Extract and build — implement the selected capability as a new microservice with its own data store. Migrate the relevant data. Run dark launches or a Parallel Run to validate correctness.
- Redirect — update the facade to route requests for that capability to the new service. The monolith no longer handles it. Repeat for the next capability.
Over many iterations, the monolith shrinks (it is "strangled") until it handles no capabilities and can be switched off.
When to use it: Use the Strangler Fig whenever the monolith is too large, complex, or poorly understood to rewrite safely in one step; when the business cannot afford a freeze on new feature delivery during migration; or when the team needs to build confidence in microservice patterns before committing fully. It is the default recommended strategy for production monolith migrations.
When not to use it: If the monolith is small and the codebase is well understood, a targeted rewrite may be faster. Also avoid if the monolith's architecture makes clean extraction practically impossible without massive refactoring first — in that case, Branch by Abstraction (Q5) must precede the extraction.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
