What is the strangler fig pattern and how does it apply to serverless migration?

Answer

The Strangler Fig pattern (coined by Martin Fowler, inspired by strangler fig trees that grow around host trees) is a migration strategy where new functionality is built on new architecture while the old system continues operating, gradually routing more traffic to the new system until the old system can be decommissioned. Applied to serverless migration: (1) Proxy in front — place an API Gateway or NGINX proxy in front of the monolith and new serverless functions; (2) Feature-by-feature extraction — identify a bounded functionality (e.g., image processing, email notifications) and reimplement it as a Lambda function; route requests for that feature to Lambda, leaving the monolith for everything else; (3) Strangling the monolith — incrementally extract more features, each time routing more traffic to Lambda. The monolith handles less and less until it can be turned off; (4) Database strangling — extract microservice data into DynamoDB while the monolith still uses the old database; sync with change data capture until the monolith is off; (5) Risk mitigation — each extraction step is independently deployable and reversible; the monolith remains the fallback. This is safer than big-bang rewrites that try to replace everything at once.