Strangler Fig Pattern: Deep Dive

Master the proven technique for safely modernizing legacy systems without the rewrite risk

The Big Bang Problem

Only 10-25% of full system rewrites succeed.

Most organizations can't afford to wait years for a rewrite that might fail.

What is the Strangler Fig?

Named after a vine in nature that Martin Fowler observed in Queensland, Australia.

The strangler fig:

  • Germinates in a tree's nook
  • Grows gradually around the host
  • Eventually becomes self-sustaining
  • The original host may die and decompose

Perfect metaphor for legacy modernization.

The Pattern: Core Concept

Replace legacy functionality incrementally while keeping the system running.

Three key components:

  1. Facade/Proxy – intercepts all requests
  2. New services – built piece by piece
  3. Legacy system – gradually decommissioned

Both systems coexist during migration.

How Routing Works

// Facade intercepts and routes requests
export class PaymentRouter {
  async processPayment(order: Order) {
    // Check if migrated to new service
    if (await this.isMigrated(order.customerId)) {
      return this.newPaymentService.process(order)
    }

    // Fallback to legacy
    return this.legacyPaymentSystem.process(order)
  }
}

Traffic flows through the facade, not directly to legacy.

Implementation Roadmap

Step 1: Add the Facade Layer

Introduce a proxy between clients and legacy system. Initially routes 100% to legacy.

Step 2: Assess and Prioritize

Map dependencies, identify lowest-risk features to migrate first.

Step 3: Build First Service

Implement one piece of functionality as a microservice. Test thoroughly.

Implementation Roadmap (cont.)

Step 4: Flip the Switch

Update facade to route that feature's traffic to the new service.

Step 5: Monitor and Validate

Track metrics, ensure new service performs as expected.

Step 6: Rinse and Repeat

Continue migrating features incrementally until legacy is retired.

Real Example: E-commerce Migration

Company:

Mid-size retailer with monolithic PHP application

Problem:

  • Slow checkout process
  • Can't scale during Black Friday
  • Hard to add features

Approach:

  • Started with product catalog service
  • Then shopping cart
  • Then payment processing
  • Finally user authentication

Result:

18-month migration with zero downtime.

The Anti-Corruption Layer

When new services must call legacy code, use an ACL:

// ACL adapts legacy interface to modern API
class LegacyCustomerAdapter {
  async getCustomer(id: string): Promise<Customer> {
    // Call legacy SOAP service
    const xmlData = await this.legacySoap.GetCustomerById(id)

    // Transform to modern format
    return this.transformToModern(xmlData)
  }
}

Prevents legacy patterns from infecting new code.

Best Practices

Do:

  • Start with low-risk, high-value features
  • Implement comprehensive monitoring
  • Use feature flags for safe rollbacks
  • Maintain dual-write to sync data

Don't:

  • Migrate everything at once
  • Skip testing in production-like environments
  • Ignore the facade as a potential bottleneck
  • Underestimate data migration complexity

Common Pitfalls to Avoid

The facade becomes a bottleneck

  • Monitor performance religiously
  • Consider clustering/load balancing

Data inconsistency between systems

  • Implement dual-write with eventual consistency
  • Use event sourcing where appropriate

Underestimating dependencies

  • Map ALL dependencies before migrating
  • Hidden integrations will bite you

Not having a rollback plan

  • Always maintain ability to route back to legacy

When to Use Strangler Fig

Perfect for:

  • Large, complex monoliths
  • Business-critical systems that can't tolerate downtime
  • Teams that need to deliver new features during migration
  • When you lack complete understanding of legacy behavior

Not ideal for:

  • Small applications (just rewrite them)
  • Systems where you can't intercept requests
  • When complete access to legacy code is unavailable
  • Greenfield projects (obviously)

Strangler Fig vs Big Bang

| Strangler Fig | Big Bang Rewrite | | --------------------------------- | -------------------------- | | Incremental value delivery | No value until complete | | Low risk | High risk (10-25% success) | | Learn and adapt | All-or-nothing | | Can add features during migration | Feature freeze | | Requires routing infrastructure | Simpler architecture |

79% of developers report strangler implementations reduce project risk.

Key Takeaways

1. Reduce Risk Through Incremental Change

Replace one piece at a time, validate, repeat.

2. Keep the Business Running

No big bang cutover, no extended downtime.

3. Validate Early and Often

Deploy services to production early to learn fast.


The strangler fig pattern trades complexity for safety.

Start Your Migration

Week 1: Assess your monolith and map dependencies

Week 2-3: Design your facade/routing layer

Week 4: Identify the first feature to migrate (low risk, high value)

Month 2: Build and deploy your first microservice

Month 3+: Measure, learn, iterate, and scale

Resources: martinfowler.com/bliki/StranglerFigApplication.html

1 / 0