Imagine you're working on a large e-commerce application that has been running successfully for several years. Over time, the application has grown into a monolith containing product management, inventory, ordering, payments, shipping, and customer management. Now the engineering team wants to move toward microservices.
One option is to rewrite the entire application from scratch, build all the new microservices, and replace the monolith once everything is ready. But this approach is extremely risky. The existing application contains years of business logic, edge cases, and integrations. Reimplementing everything at once can take a long time, introduce unexpected bugs, and delay new feature development.
A safer alternative is to migrate the application incrementally. Instead of replacing the entire monolith, we gradually move individual capabilities into new services while the existing application continues operating. This approach is known as the Strangler Fig Pattern.
In this chapter, we'll understand how the pattern works, how to implement it, and how to handle the practical challenges of migrating a production application.