TecnoStack
Start a projectالعربية
Network: Routing layer, Callers, Legacy system, New loyalty service.
Product & strategy

The strangler fig pattern replaces a legacy system one capability at a time behind a routing layer. Pick a first slice you can bound, give every data set one writer, and write the rollback before each cutover.

In this article

Silent video with on-screen text. The transcript below repeats every screen and describes what it shows.

Watch on the video page

  1. 0:00–0:05

    Strangler fig migration; Illustrative diagram; TecnoStack; 1 2 3 4 5 6; Strangler fig migration; Replace one capability at a time; Plan each transition; Legacy system; One big rewrite; Capability by capability

    Branching diagram: Legacy system, One big rewrite, Capability by capability. Connections: Legacy system to One big rewrite; Legacy system to Capability by capability. Emphasis: Capability by capability.

  2. 0:05–0:10

    Strangler fig migration; Illustrative diagram; TecnoStack; 1 2 3 4 5 6; 01; Route capability by capability; Preserve a clear ownership boundary; Routing layer; Callers; Legacy system; New loyalty service

    Network: Routing layer, Callers, Legacy system, New loyalty service. Connections: Callers to Routing layer; Routing layer to Legacy system; Routing layer to New loyalty service. Emphasis: Routing layer.

  3. 0:10–0:15

    Strangler fig migration; Illustrative diagram; TecnoStack; 1 2 3 4 5 6; 02; One authoritative writer; Transfer ownership after reconciliation; Legacy owns writes; Transfer ownership; Retire sync

    Sequence: Legacy owns writes, Transfer ownership, Retire sync. Connections: Legacy owns writes to Transfer ownership; Transfer ownership to Retire sync. Emphasis: Transfer ownership.

  4. 0:15–0:20

    Strangler fig migration; Illustrative diagram; TecnoStack; 1 2 3 4 5 6; 03; Shadow without side effects; Then move reads and ownership; Compare outputs; Move reads; Move writes; Retire after checks

    Flow: Compare outputs, Move reads, Move writes, Retire after checks. Connections: Compare outputs to Move reads; Move reads to Move writes; Move writes to Retire after checks. Emphasis: Move writes.

  5. 0:20–0:25

    Strangler fig migration; Illustrative diagram; TecnoStack; 1 2 3 4 5 6; 04; Plan recovery before cutover; Reconcile data before switching routes; Pause new writes; Reconcile data; Restore old ownership

    Flow: Pause new writes, Reconcile data, Restore old ownership. Connections: Pause new writes to Reconcile data; Reconcile data to Restore old ownership. Emphasis: Reconcile data.

  6. 0:25–0:30

    Strangler fig migration; Illustrative diagram; TecnoStack; 1 2 3 4 5 6; TECNOSTACK; Track every retirement; Finish the migration deliberately; Modernization map; Exit criteria per slice; Retirements tracked; Architecture review; tecnostack.com

    Comparison without scores: Modernization map, Exit criteria per slice, Retirements tracked, Architecture review. Emphasis: Retirements tracked.

The strangler fig pattern replaces a legacy system one capability at a time instead of in a single rewrite. You put a routing layer in front of the old system, move each capability to a new component behind it, and switch the old part off once nothing depends on it. Old and new run side by side throughout.

The pattern is easy to describe. Projects succeed or stall on three decisions: which capability to move first, who owns each piece of data while both systems run, and how to cut over in steps you can reverse. This guide covers those three. If your goal is to add AI features to an old system rather than replace it, read about rolling out an LLM in stages or the legacy LLM blueprint instead.

The strangler fig pattern is incremental replacement behind a facade. A proxy intercepts requests meant for the legacy system and sends each one either to the old code or to a new service, so users keep one interface while functionality moves across. AWS Prescriptive Guidance and Microsoft's Azure Architecture Center both document it this way.

Martin Fowler named it after the strangler figs he saw in Queensland's rain forests. The fig seeds in a host tree, grows down until it roots, and ends up standing on its own in the host's shape. Fowler's original name, "Strangler Application", became "Strangler Fig Application" because the shorter name suggested violence.

Microsoft describes four phases: the facade first routes most traffic to the legacy system, shifts more to the new system with each iteration, routes everything there once the old system has no dependants, and is finally removed.

The pattern fits large systems you can intercept and split. It fits poorly when you cannot intercept requests, or when the system is small enough that a careful replacement is simpler.

Good fitPoor fit
Callers reach the system through HTTP endpoints, APIs, queues or file drops you can redirectRequests cannot be intercepted, and you cannot change the code or the database
Business capabilities can be separated, each with its own inputs, outputs and dataEverything happens in shared stored procedures with no seams
The old system can keep running for months while you migrateYou must switch the old system off quickly
The business needs new features during the migrationThe system is small and replacing it outright is simple

The poor-fit rows come from Microsoft's and AWS's guidance. A database-centric system is not automatically ruled out: Microsoft notes that triggers or change data capture on the legacy database can send events to new services without changing the application code.

A common trigger for legacy system modernization is a framework or runtime that is leaving support. Check the framework support windows for your backend first: sometimes an upgrade of your Magento store buys enough time, and sometimes it is the moment to start moving slices.

A slice is one business capability with its own inputs, outputs and data, such as loyalty points, delivery quotes or customer notifications. Choose one you can bound clearly and that matters, without picking the capability where an outage would hurt most.

A good first slice passes four checks:

  • You can describe its boundary in one sentence.
  • You can list every caller from logs or traffic capture, not from memory.
  • It matters enough to prove value to the business.
  • Few other modules write to its data.

Map the callers and the data before writing new code. A hidden consumer, such as a nightly report that reads a table directly, is a common reason a migrated capability breaks something. AWS also warns that splitting too early is costly when the domain is unclear, because you can draw the service boundaries in the wrong place.

Write the slice’s readiness record

This original worksheet makes the first slice reviewable. Record evidence and a responsible owner for each row. An empty row is an unresolved dependency, not a reason to assume the old path is unused.

Readiness questionEvidence before moving ownership
What is inside the slice?Named operations and exclusions, with accepted business outcomes
Who still calls or reads it?Routes, jobs, reports, exports and direct database dependencies
Who owns writes now and next?Authority boundary, in-flight work and fencing procedure
How do identifiers correspond?Reviewed mapping and rules for duplicates, deletions and versions
How is the new state checked?Item-level reconciliation, exceptions and agreed acceptance cases
How can recovery proceed?Compatible old state or an alternative recovery path, with a decision owner
What proves retirement is ready?Remaining dependencies removed or explicitly retained, with retention and access decisions

For a loyalty slice, include the finance report that reads the old balance table and the return process that reverses earned points. A quiet HTTP endpoint does not prove those consumers have disappeared. Use the requirements brief to agree the business cases before choosing a migration mechanism.

Rehearse the routing layer and its failure behaviour before introducing it into production. Begin by forwarding the agreed paths to the legacy system unchanged, then verify routing, logs and performance before moving a capability. Record any callers that bypass this layer; a proxy does not automatically cover database readers, scheduled jobs or file transfers.

The routing layer can be an API gateway, a reverse proxy or a module inside the application. What matters is that it is reliable, observable and quick to change. AWS and Microsoft both warn that the proxy can become a single point of failure or a performance bottleneck, so run it with the same redundancy and monitoring as the system behind it.

Rules can match a path, an operation, a customer group or a feature flag. Keep them in version control, review them like code, and make sure you can trace each response to the component that produced it.

Diagram: Routing layer, Callers, Legacy system, New loyalty service. Connections: Callers to Routing layer; Routing layer to Legacy system; Routing layer to New loyalty service.

Figure 1: Route capability by capability. Preserve a clear ownership boundary.

Two more pieces sit beside the router. Legacy modules that still call a migrated capability need an anti-corruption layer: an adapter that translates their old calls into the new interface, so the new design does not inherit legacy conventions. And each new component should expose a versioned interface, the same discipline as API contracts from day one, so a later migration can strangle it in turn.

If you were planning to use AWS Migration Hub Refactor Spaces as the router, check its status first. As of October 2026, AWS's strangler fig page says the service stopped accepting new customers on 7 November 2025 and points to AWS Transform.

For the migration approach in this guide, give each data set one authoritative writer at a time. This makes ownership and recovery explicit; it is a chosen engineering discipline, not a claim that every distributed system must use the same design.

  1. Before cutover, the legacy system owns the data. The new component reads a synchronized copy, from change events or scheduled exports, and accepts no authoritative production writes.
  2. At cutover, ownership moves. Stop the old writer, drain in-flight work, catch up and reconcile the new copy, then enable the new writer. Changes flow back to the legacy database only for consumers that still need them.
  3. After retirement, remove the sync together with the legacy code that depended on it.

AWS's version of step 2 uses a queue and a synchronizing agent that keeps the monolith's database current from the new service's events, and it calls the result eventually consistent. AWS recommends treating that sync as a tactical fix until a long-term design is in place. Set its end date when you switch it on.

Diagram: Legacy owns writes, Transfer ownership, Retire sync. Connections: Legacy owns writes to Transfer ownership; Transfer ownership to Retire sync.

Figure 2: One authoritative writer. Transfer ownership after reconciliation.

Avoid open-ended dual writes, where application code writes every change to both systems: when one write fails, the systems can drift even if the error is reported. A logged failure does not repair the missing change. Keep one owner and one sync path, and:

  • capture changes in durable storage and make replay idempotent, so a retry cannot apply a change twice;
  • handle event ordering, deletions and schema versions explicitly;
  • keep a table that maps legacy identifiers to new ones from day one, because reconciliation, support queries and rollback all need it;
  • reconcile the two copies on a schedule and alert on differences.

Move each slice through four stages, and write the rollback for each stage before you start it.

StageWhat movesHow you roll back
1. CompareApproved read comparisons, or isolated simulated writes with external effects disabledStop the comparison; production write ownership has not moved
2. Move readsThe new component serves reads; legacy still owns writesSwitch the read route back
3. Move writesWrite authority transfers to the new componentFence the new writer, reconcile its changes into the legacy data, then switch the route
4. RetireLegacy path, sync and data objects are removedRestore objects and replay changes: slow and risky, so treat it as final

Stage 3 is where teams get hurt. A gradual rollout of writes works only across partitions you can separate safely, such as stable tenant or customer keys. Never split writes for the same records between both systems. If you cannot partition ownership, hand the capability over as one unit.

Switching a route back does not undo what the new component wrote or sent, so rehearse the data handoff as well as the route switch. In Microsoft's database example, rollback remains possible during the documented coexistence stages, but removing tables and sync introduces restoration and replay work. Keep the recovery records you need before any destructive schema cleanup.

Each rollback plan names the signals that trigger it, the person who decides, and the exact steps. Before stage 3, have the people who will run cutover day walk through the plan end to end.

This example is illustrative and not a client case. A retailer's ERP handles orders, stock and loyalty points. Loyalty has clear inputs (completed orders and returns) and clear outputs (balances at checkout and in the app), so the team picks it as the first slice.

The team puts a pass-through router in front of the ERP's loyalty endpoints, builds the new loyalty service, feeds it order events and compares its balances with the ERP's. Once they agree, balance reads move to the new service. Then the service takes ownership of loyalty transactions, and a one-way sync keeps the ERP's loyalty table current for a finance report that still reads it. When the team rebuilds that report, they remove the sync and the old loyalty module.

Reconcile events as well as the final balance

Extend the hypothetical loyalty example with an opening balance of 100 points. Four event arrivals represent three distinct operations. The second arrival of L-101 has the same identity and payload as the first; it is a retry of that operation, not a separate purchase.

ArrivalOperationApplied changeExpected balance
L-101Earn points for a completed order+20120
L-102Reverse part of the earned points after a return-5115
L-101 againMatching retry already recorded0115
L-103Redeem points-10105

The correct closing balance is 105, not 125 from applying the earned-points event twice. Verify the source identity, customer mapping and stored operation outcomes. If the same event identity arrives with different content, record a conflict for investigation instead of silently treating it as the same valid retry.

This small fixture checks one failure path; it does not prove the complete migration. Also agree rules for out-of-order events, missing returns, insufficient balances and records created during cutover. Compare the operations and exceptions as well as totals, because matching totals can hide offsetting errors.

Before enabling the new writer, prove that pending work is accounted for and that the old writer cannot continue for the same ownership partition. If new records cannot be represented by the old schema, a route reversal is not a workable recovery plan. Agree a compatible transformation, restoration/replay procedure or forward recovery before accepting that transition. The deployment recovery guide separates those decisions from merely deploying an older version.

The quiet failure is a migration that never finishes. Treat each retirement as a deliverable with the same weight as a launch.

  • Keep a one-page map showing each capability as legacy, in transition or migrated.
  • Set exit criteria for each slice before it starts, including sync, legacy objects and background consumers. Separate operational retirement from any data deletion subject to retention requirements.
  • Assign an owner to the routing layer, and decide at the start whether it is removed at the end or kept as an adapter for legacy clients.
  • If a vendor builds part of the migration, agree what a vendor handover should include: routing rules, sync jobs, runbooks and the identifier mapping, not only the new code.

Pick one capability, inventory its callers and data dependencies, and write down current ownership. Complete the readiness record, rehearse the selected boundary and plan the comparison stage with its recovery steps before changing production routing.

TecnoStack’s custom software service can scope the first slice, integration boundaries and operating handover. Review existing managed cloud hosting responsibilities separately. If a capability could be replaced by a product, use the SaaS or custom framework before deciding to rebuild it.

  • Amazon Web Services. Strangler fig pattern, AWS Prescriptive Guidance: proxy layer, anti-corruption layer, data synchronization, applicability, and the Refactor Spaces notice.
  • Microsoft. Strangler Fig pattern, Azure Architecture Center: the four phases, when not to use the pattern, and the database cutover and rollback example.
  • Martin Fowler. Strangler Fig Application: the origin of the name and the case for gradual modernization.

The data-ownership, cutover and rollback recommendations in this article are TecnoStack's engineering guidance, not requirements set by AWS, Microsoft or Martin Fowler. Sources checked on 24 October 2026. The event worksheet is an original hypothetical fixture with independently reconciled arithmetic.

Discuss your website, store, app or AI project in Arabic or English. We agree the scope before work starts.

Book a free scoping callCompare services and prices