Reading time: 7 min Tags: Legacy Systems, Modernization, Architecture, Project Planning, Risk Management

The Strangler Fig Strategy: Modernize Legacy Software Without a Big Bang Rewrite

Learn a practical, step-by-step approach to modernizing legacy software by gradually replacing pieces behind stable interfaces, reducing risk while improving reliability and delivery speed.

Legacy systems usually do two things at once: they keep the business running and they slow the business down. The classic response is to propose a full rewrite, but “big bang” rewrites are expensive, risky, and often deliver value only at the very end.

The Strangler Fig strategy is a safer alternative. You keep the existing system in place, gradually route selected functionality to new components, and retire old parts as they become unnecessary. Done well, you get steady progress, fewer outages, and clearer architecture without betting the company on a multi-year rewrite.

This post explains how to apply the pattern in a way that works for small and medium teams, including a concrete example, a checklist you can copy, common mistakes, and when you should choose a different approach.

What the Strangler Fig Strategy Is

The idea comes from a vine that grows around a tree, eventually replacing it. In software, you “grow” new components around the legacy system by intercepting requests or workflows and handling some of them with new code. Over time, more traffic moves to the new components until the old system can be removed.

Practically, the pattern has three repeated steps:

  1. Identify a slice of functionality that can be isolated, like a report, a checkout flow, or an internal admin page.
  2. Create a seam where you can route that slice to new implementation while keeping behavior stable.
  3. Migrate and retire incrementally, measuring correctness and performance as you go.

What makes the Strangler Fig approach powerful is that it embraces mixed states. For a while, part of the system is modern and part is legacy. Your job is to manage that overlap intentionally with good boundaries and observability.

Key Takeaways
  • Modernization succeeds when you replace interfaces and flows, not just code.
  • Start small: pick a slice with clear inputs and outputs, then repeat the pattern.
  • Invest early in routing, contracts, monitoring, and rollback, because these reduce risk across every later step.
  • Keep data ownership explicit; ambiguous data boundaries are the #1 source of “stuck halfway” migrations.

Start With Outcomes and Boundaries

Before you build anything new, define what “better” means. Common outcomes include faster release cycles, fewer incidents, easier onboarding, better performance in specific endpoints, or the ability to add a feature the legacy system makes painful.

Then pick a boundary that makes sense to modernize first. Strong candidates are areas that are:

  • High change frequency (you touch it often and it slows you down).
  • Operationally risky (incidents cluster there).
  • Conceptually coherent (it can be described in a sentence).
  • Testable (you can validate behavior with inputs and outputs).

Be explicit about ownership of data and business rules inside that boundary. If you cannot describe which system is the source of truth for a piece of data during migration, you are not ready to cut the seam yet.

Design the Seam: Routing and Contracts

The seam is where old and new systems meet. It could be an API gateway, a reverse proxy, a UI router, a background job dispatcher, or even a function-level toggle inside the legacy code. The seam should make it easy to (1) route requests, (2) observe behavior, and (3) roll back safely.

At minimum, your seam design should answer:

  • How does traffic get routed? By URL path, tenant, feature flag, percentage, or workflow state?
  • What is the contract? Request/response schema, error handling, and timeouts.
  • How do we compare outcomes? Metrics, logs, and success definitions.
  • How do we roll back? One switch, and you are back on the legacy path.

Pick a contract you can live with

Contracts are sticky. If you expose a messy internal legacy data shape to the new system, you will carry that mess forward. If you design a contract that is too idealized, you will spend months building adapters and arguing about edge cases.

A pragmatic contract is “stable but not perfect.” It should:

  • Represent business meaning (for example, orderStatus), not database details (for example, status_code in three tables).
  • Include a versioning plan if you expect change (even a simple v1 path or header).
  • Define error behavior clearly (what errors are retriable, what errors are user-facing).

Conceptually, the seam often looks like this:

Client request
  -> Router/Seam (decide legacy vs new)
      -> Legacy handler (existing system)
      -> New handler (new component)
  -> Shared observability (logs, metrics, traces)
  -> Rollback switch (route everything to legacy if needed)

A Concrete Example: Orders Service Extraction

Imagine a mid-sized ecommerce business with a single monolithic web app. The team struggles most with order creation and fulfillment logic: it is tightly coupled, releases are scary, and a small change can break checkout.

They decide to “strangle” the order functionality first, without rewriting the whole app.

Phase 1: Establish the seam

The team adds a routing layer in front of the monolith for a small set of endpoints, starting with POST /orders. Initially, the router forwards everything to the monolith, but it now has the ability to route some requests to a new service.

Phase 2: Build the new service behind the same contract

They implement a new Orders service that accepts the same request schema and returns the same success payload, including error codes the frontend expects. They do not attempt to “improve everything” yet. The goal is compatibility first.

To reduce risk, they start with a small rollout. For example, internal staff accounts are routed to the new service while customer traffic stays on the monolith.

Phase 3: Deal with data ownership deliberately

The hardest decision is data. The monolith owns the database, but the new service needs to write orders. The team chooses an intermediate step: the new service writes to its own database and also emits an event that the monolith can consume to keep legacy screens working during transition.

This is not “perfect architecture,” but it is clear. The Orders service is the source of truth for new orders, and the monolith becomes a consumer for any remaining legacy dependencies.

Phase 4: Retire the legacy path and expand the boundary

After weeks of stable operation and good monitoring, they increase traffic percentage to the new service and eventually route all order creation there. Then they repeat the process for order status updates, fulfillment, and refunds, each time expanding the new system’s surface area and shrinking the monolith.

Notice what they avoided: a long period of “rewrite in a branch.” Instead, they created a safe path to ship value continuously while steadily reducing reliance on the legacy code.

Migration Checklist

Use this as a copyable checklist for each slice you modernize:

  • Define the slice
    • What user or internal outcome improves?
    • What endpoints, pages, jobs, or workflows are included?
    • What is explicitly out of scope?
  • Design the seam
    • Routing decision rule (path, tenant, percentage, flag).
    • Contract (schema, timeouts, errors, versions).
    • Rollback method that is fast and boring.
  • Data plan
    • Source of truth for each field during migration.
    • Read path and write path, including any replication or eventing.
    • Backfill and reconciliation approach if needed.
  • Validation
    • Golden test cases for the slice (happy path and edge cases).
    • Metrics that define success (error rate, latency, correctness checks).
    • Alerting and dashboards tied to the new component.
  • Cutover
    • Rollout plan (internal users, canary, percentage ramp).
    • Runbook for rollback and incident response.
    • Decommission plan for the old code path once stable.

Common Mistakes to Avoid

Mistake 1: Migrating a “blob” instead of a slice

If the boundary includes many unrelated behaviors, you will spend your time chasing hidden coupling. Pick the smallest unit that still delivers a meaningful outcome, then iterate.

Mistake 2: Ignoring observability until after launch

The overlap period is where you need the most visibility. Build logs and metrics into the seam and the new component early, including correlation IDs so you can trace requests across both worlds.

Mistake 3: Letting “temporary” data duplication become permanent by accident

Dual writes, shadow tables, and replicated fields can be valid transitional tools, but only if you track them. Maintain a living list of “migration artifacts” that must be removed, and schedule the cleanup as part of the modernization work.

Mistake 4: Breaking contract compatibility in small ways

Minor differences in error codes, null handling, sorting, or time zones can cause real production issues. Treat compatibility as a product requirement. When you must change behavior, version the contract instead of silently altering it.

When Not to Use This Approach

The Strangler Fig strategy is versatile, but it is not always the right tool. Consider alternatives if:

  • You cannot create a seam without massive intrusion. If routing cannot be controlled safely, incremental replacement may be harder than it looks.
  • The legacy system is already near end-of-life in a way that makes incremental investment wasteful, such as an unmaintainable platform with critical security constraints.
  • The domain is small and stable and a replacement is genuinely straightforward. Sometimes a clean rebuild of a tiny system is less total work.
  • Regulatory or operational constraints require full parallel certification and cutover with strict validation that you cannot practically do slice by slice.

If you decide against Strangler Fig, you can still apply its mindset: define clear contracts, measure outcomes, and plan rollback, even for more traditional migrations.

Conclusion

Modernizing legacy software is less about heroics and more about controlled change. The Strangler Fig strategy works because it forces you to create safe seams, move in small increments, and keep rollback and measurement in the foreground.

Pick one slice, make the contract real, build the seam, and ship. Then repeat until the “legacy” part is small enough to delete confidently.

FAQ

Do I need microservices to use the Strangler Fig strategy?

No. The new component can be a module, a separate app, or even a new UI bundle. The key is the seam and the routing, not the deployment style.

How do we handle shared databases during the migration?

Shared databases are common early on, but they increase coupling. If you must share, define strict ownership (who writes what) and plan a path toward decoupling, such as events, replication, or dedicated tables that later move behind a service.

What is the smallest first slice you recommend?

Start where you can create clear input and output boundaries. A single endpoint, a report, or a background job is often easier than a complex UI flow, especially if you can test it with a fixed set of cases.

How do we prove the new behavior matches the old behavior?

Use a mix of contract tests, golden test cases, and production-safe comparisons. For example, you can run the new logic in “shadow mode” and compare outputs without affecting users, then promote it to active routing once it is consistently correct.

When should we delete the old code?

Delete legacy paths once traffic is fully routed away and you have monitored stability through at least one normal operational cycle for your business. Keep the deletion as a planned deliverable, not an optional cleanup.

This post was generated by software for the Artificially Intelligent Blog. It follows a standardized template for consistency.