{"canonical_url":"https://engineer.company/glossary/strangler-fig-pattern/","content_markdown":"# Strangler fig pattern\n\n## What it is\n\nThe strangler fig pattern replaces a running system in stages by gradually\nmoving pieces of its work to a new implementation. A routing layer or another\nstable entry point decides which implementation handles each operation. Users\ncan keep working while the team completes the new path a piece at a time. The\nolder path is removed once its responsibilities, relevant data and consumers\nhave moved.\n\nThe choices available depend on the public interface and the existing state. An\nHTTP service might route particular paths or groups of accounts to a\nreplacement. A worker can direct a defined class of jobs to a new consumer. A\ndata service might move a read operation before moving the write that owns the\nunderlying structure. Give the choice an observable rule. An operator should be\nable to tell which version received an operation and why.\n\nReplacement is also a question of ownership. Two implementations can serve the\nsame public surface during the transition while an underlying decision still has\none authoritative owner. Decide where writes go, what data other components can\nread, and how the old behaviour remains available for recovery. Routing is one\npart of the migration. Data consistency and user-visible outcomes need their own\nevidence.\n\n## Why it matters\n\nLarge systems often have more behaviour than a replacement team initially knows.\nAn unusual error code might drive retries in a client. A field that looks\noptional could supply a required report default. Moving one operation at a time\ngives the team a chance to discover those expectations while the rest of the\nsystem continues to operate. The lessons from the first slice can inform later\nones.\n\nA staged change can also make recovery more focused. If a new read path handles\none part of the workload, switching that path back may be possible while the old\ndata remains compatible. Once a new implementation owns writes or introduces a\nnew representation, recovery can require a data plan. Establish those conditions\nbefore treating a route switch as the complete rollback procedure.\n\nThe cost of a long transition can become substantial. Both implementations may\nneed maintenance, and the routing layer adds another place to observe and\nunderstand. Choose slices that retire a real responsibility and keep a clear\nlist of remaining consumers. A transition has made progress when it moves a\nbehaviour and gives the team a credible way to remove the old part.\n\n## What it looks like in practice\n\nImagine replacing an API for customer order history. Put the existing public\nroute behind an entry point that can choose the implementation. Move one read\noperation first. Compare the old and new response for representative records,\nincluding an unknown record and a record with optional fields. Compare outcomes\nthat callers interpret, such as error status, ordering and pagination. Use a\ncommon operation identifier so observations from both paths can be compared.\n\nSwitch a limited part of traffic after the comparison has passed. Record the\nselected implementation on the service side without changing the response\ncontract. Test a representative slow request and an unavailable dependency. The\noperator should know when to keep a request on the new route, when to restore\nthe old one and how to make sure the data remains readable by both. Explicit\nobservations make the route switch a measured operation.\n\nEngineer's\n[typed API migration case study](/portfolio/migrated-the-api-to-huma-v2-at-100-parity/)\ndescribes moving routes to Huma over the existing Fiber runtime and verifying\nthat registered routes and the published API description agree. It shows the\nvalue of checking parity along the way. The order-history example extends that\nreasoning to a migration that routes users between implementations. If the old\nresponse makes a documented promise, add a separate case to verify that the\nreplacement still fulfils it.\n\nBefore moving a write, rehearse the ownership transition and its failure modes.\nRecord which path is authoritative at each stage and how it handles a retry from\na client that saw an uncertain result. Test what a read sees before and after\nthe change. These checks can distinguish a successful move of the route from a\nsuccessful move of the durable responsibility behind it.\n\n## Where it goes wrong\n\nA common problem is leaving both implementations active without a retirement\nplan. As the routing logic grows, some users can remain on an old path because\nthey fall into an untested case. Confirm each migrated route and the consumers\nthat still use it. Write down what can be removed after the final supported\nrequest has moved and which archived data remains useful for recovery or\ncompliance.\n\nShared writes can create another problem. If a request is sent to two stores and\nonly one commits, the systems have different histories. Avoid treating two\nacknowledgements as one durable outcome. Give one path authority during each\nphase and decide how any replicated view catches up. Use stable event or\noperation identities, and test the state after interruptions at the boundary.\n\nFinally, measure responses throughout the move. A switch can preserve status\ncodes but increase latency, change the way a result is sorted, or remove a piece\nof context a caller depends on. Use a small group of relevant observations and\nverify them at the actual entry point. A staged replacement works when the team\ncan explain which behaviour now belongs to the new system, how users can recover\nafter a failure and why the old part can be retired.\n\n## Further reading\n\n- [Microsoft Azure Strangler Fig guidance](https://learn.microsoft.com/en-us/azure/architecture/patterns/strangler-fig).\n  Discusses staged replacement through a preserved entry point.\n- [AWS prescriptive guidance on the Strangler fig pattern](https://docs.aws.amazon.com/prescriptive-guidance/latest/cloud-design-patterns/strangler-fig.html).\n  Describes migration and routing trade-offs.\n- [Amazon API Gateway HTTP API routes](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html).\n  Gives a concrete example of request route selection.\n\n\u003chttps://engineer.company/glossary/strangler-fig-pattern/\u003e\n","date_modified":"2026-11-25T07:18:46Z","description":"Start with one route, compare observable results and decide when authoritative data ownership can move safely.","formats":{"gemtext":"https://engineer.company/glossary/strangler-fig-pattern/index.gmi","gopher":"https://engineer.company/glossary/strangler-fig-pattern/gophermap","html":"https://engineer.company/glossary/strangler-fig-pattern/","json":"https://engineer.company/glossary/strangler-fig-pattern/index.json","markdown":"https://engineer.company/glossary/strangler-fig-pattern/index.md","pdf":"https://engineer.company/glossary/strangler-fig-pattern/index.pdf"},"kind":"page","language":"en","title":"What is a strangler fig pattern?","url":"https://engineer.company/glossary/strangler-fig-pattern/","version":1}