The Strangler Fig pattern migrates legacy systems gradually. After using it in production, here’s how to apply it effectively.

What is Strangler Fig?

Strangler Fig:

  • Gradual migration - Replace incrementally
  • Low risk - Small changes
  • Parallel systems - Old and new coexist
  • Incremental routing - Traffic migration

Migration Strategy

Phase 1: Intercept

Old System → Router → New System (intercepts)

Phase 2: Migrate Features

Feature A → New System
Feature B → Old System
Feature C → New System

Phase 3: Complete Migration

All Features → New System
Old System → Deprecated

Implementation

Router Configuration

// Route based on feature
function routeRequest(req) {
    const feature = detectFeature(req);
    
    if (isMigrated(feature)) {
        return routeToNewSystem(req);
    } else {
        return routeToOldSystem(req);
    }
}

Feature Flags

const migratedFeatures = {
    'user-management': true,
    'order-processing': false,
    'payment': true
};

function routeRequest(req) {
    const feature = getFeature(req);
    
    if (migratedFeatures[feature]) {
        return newSystem.handle(req);
    } else {
        return oldSystem.handle(req);
    }
}

Best Practices

  1. Start small - Migrate one feature
  2. Test thoroughly - Verify behavior
  3. Monitor closely - Track metrics
  4. Rollback plan - Quick revert
  5. Document progress - Track migration
  6. Team alignment - Clear communication
  7. Gradual rollout - Phased approach
  8. Complete migration - Don’t leave partial

Conclusion

Strangler Fig enables:

  • Low-risk migration
  • Gradual replacement
  • Parallel systems
  • Incremental routing

Start with one feature, then expand. The pattern shown here migrates legacy systems safely.


Strangler Fig pattern from November 2022, covering gradual migration strategies.