Course contentsShow
← Cloud and Infrastructure
Lesson 2514 of 2,98954. Serverless ArchitecturesFree lesson

Strangler Fig Pattern for Migration

Gradually replace monolithic components with serverless functions by routing traffic incrementally.

Strangler Fig Pattern for Migration

What you'll learn: How to safely migrate a monolithic application to serverless by gradually replacing pieces while keeping the system running.


The Core Idea

The Strangler Fig Pattern is a gradual migration strategy where you incrementally replace components of a legacy monolithic application with serverless functions, routing traffic to new implementations piece by piece. Like the strangler fig tree that grows around a host tree and eventually replaces it, your new serverless architecture slowly wraps around and replaces the old system.

Why This Matters

Rewriting an entire monolith in one go is risky and disruptive. The Strangler Fig approach lets you:

  • Minimize risk by migrating small, isolated features first
  • Maintain service continuity during the transition
  • Roll back easily if a migration fails
  • Prove value incrementally before committing fully

How It Works

You place a routing layer (often an API Gateway) in front of both old and new systems. Start by identifying a low-risk feature—perhaps a user profile lookup or report generation. Implement that feature as a serverless function, then gradually shift traffic from the monolith to the new function. Monitor, validate, then move to the next component.

Over time, more traffic flows through serverless functions while the monolith shrinks. Eventually, the monolith can be retired completely.

The Migration Flow

  1. Route all traffic through an API Gateway initially pointing to the monolith
  2. Identify one feature to extract and build as serverless functions
  3. Update routing rules to direct that feature's traffic to the new implementation
  4. Monitor and validate behavior matches expectations
  5. Repeat for additional features until the monolith is fully replaced

Key Takeaway: The Strangler Fig Pattern enables safe, incremental migration from monoliths to serverless by routing traffic progressively to new implementations, reducing risk and allowing continuous validation at each step.