TL;DR
Switching an old system over in one night means rebuilding a moving target, finding every hidden rule at once, and betting everything on one switch. Instead, we put a front door in front of the old system and move one slice at a time, checking each slice before customers rely on it. That's a strangler fig migration.
- A front door (aka a facade) sits in front of the old system and decides where each request goes, so moving a slice, or sending it back, is a one-line change.
- Shadow traffic sends a copy of real requests to the new system and hides its answers. A parity check then compares both systems, and it caught a 4:12pm order the new code would have promised a day early.
- One system owns each table at a time, and everything else reads a copy. Anything that reads a table, like a 4:05pm prep sheet, has to move with it or know where to look.
- Migrations often stall right before the scariest slice, so plan the last slice and a turn-off date on day one.
When Crumb & Co. bought Rolling Pin Bakeries, we got six more shops, a whole lot of sourdough fans, and Pinwheel, the ordering system all six of those shops run on. It was built in PHP back in 2011, and it has no tests and no API. Yara, who leads Rolling Pin's two-person ordering team, has kept it running for years.
In February, our team got stuck. Wren wanted to rewrite the rest of Pinwheel in one go, and Yara wanted to keep replacing it one piece at a time. In this article, we're going to look at why one big switch is such a risky bet, and how we can replace an old system piece by piece while our shops keep selling bread.
Onwards!
Meet Pinwheel
Before we replace anything, we need to know what Pinwheel actually does for our six new shops:

Two of these jobs never involve a customer. At 2am and again at 4am, Pinwheel imports orders from a CSV file (it chokes above about 500 orders per file, so it runs twice). At 4:05pm, it prints the prep sheet our evening crew uses to shape tomorrow's sourdough for an overnight proof.
That print is why our next-day orders close at 4pm, a cutoff that Gus, Rolling Pin's founder, set years ago. Pinwheel's code never explains it. It just has the hour 16 typed into four files (Chesterton's Fence digs into why), and whatever replaces Pinwheel will have to get all four of them right.
A Front Door for Pinwheel
Our first change to Pinwheel was a small one. In December, Wren's memo asked for an order API, so Biscuit could stop sending its orders through a CSV file. Our owner approved it, Wes (who came over from Rolling Pin) and Yara started building it on January 6, and on February 1, Biscuit switched over:

Our API passes every order straight into Pinwheel, so nothing changes for our shops, and the CSV import stays on until the API has had a clean week, so Biscuit always has a way back.
Over the next few weeks, Pinwheel's own order form and our shops' screens will start using the same API too:

Our customers won't notice a thing. That's on purpose. What we gained is one spot where we can send any kind of order somewhere other than Pinwheel. A door like this, sitting in front of an old system and deciding where each request goes, is called a facade. It's the same move as a model gateway, where every request passes through one service in the middle.
The February Deadlock
With the API working, Wren wanted to finish the job in one go. We would rebuild the rest of Pinwheel inside our own system, with coding agents doing most of the typing. Then, one Sunday night in late October (right before Rolling Pin's November 1 to January 5 change freeze), all six shops would switch over at once:

This is called a big-bang rewrite. We build something nobody uses for months, and then everybody uses it at once. Yara pointed us to the top row. Pinwheel keeps changing while we rebuild it, so every new loaf and every new price gets built twice.
She also pointed out that our rewrite has to find every rule nobody wrote down, all before that one night:

Pinwheel has no tests (Tests for Agent Code shows how to add the first ones), so nothing will warn us when we miss one of these. We'll find out when something breaks, and with a big-bang switch, everything breaks on the same morning:

Going back won't save us either, because Pinwheel never saw any of the orders placed since Sunday night.
We aren't the first people tempted by this plan. In April 2000, Joel Spolsky wrote Things You Should Never Do, Part I about Netscape rewriting its browser from scratch. He called it "the single worst strategic mistake that any software company can make", and Netscape's version numbers tell the story:

Spolsky's point was that old code is full of hard-won bug fixes, and a rewrite throws all of them away.
So, who was right? Both of them, kind of. Pinwheel can't run forever, so Wren and Yara settled it with an experiment. We would rebuild just the evening prep sheet next to Pinwheel, with a hard two-week limit (aka a time box), and see how it went.
One Slice at a Time
That prep sheet became our second slice, which is one piece of Pinwheel's work that can move on its own. Here are all of our slices, from least risky to most risky:

Biscuit's orders were our first slice. The prep sheet came next, and it left the 4pm cutoff exactly where Gus put it. For two weeks, both sheets printed every evening, and Yara compared them line by line:

Checking that an old system and a new one produce the same output like this is called a parity check. Once the sheets matched evening after evening, our kitchen printer switched to the new sheet, and Pinwheel's print job stayed around as our way back.
Gift cards moved next, with one new rule in our front door:

Our customers buying a gift card don't notice a thing, and Pinwheel just got a little smaller. That leaves next-day orders, the slice with all of the scary rules.
Watching a Slice Before It Goes Live
How will we know our new version of next-day orders gets every rule right? For two weeks, our front door will send each next-day order to Pinwheel as usual. It will also send a copy to our new system, and that answer goes into a log instead of back to our customer:

Pretty sneaky, right? Our customers only ever see Pinwheel's answers, while our new system works on real orders with real typos. Sending a copy of live traffic to a new system and hiding its answers like this is called shadow traffic.
Every morning, we run a parity check on the totals, pickup days, and prep sheet lines:

Look at order 20417, placed at 4:12pm on a Monday. Pinwheel says pickup is Wednesday, because Monday's prep sheet had already printed. Our new system says Tuesday, so a customer would show up for a loaf nobody made. Our agent ported the 16 in public/order.php, but it missed the copy in includes/mail.php, which is where Pinwheel works out the pickup day. Wes spots it in the log, and no customer ever sees it.
GitHub did this when it rewrote its permissions code, using an open-source library called Scientist that runs old and new code side by side and logs every mismatch. Jesse Toth's write-up calls behavior on production data "the only true test of its correctness".
Turning the Dial
Once the mismatches stop, real customers get our new version, starting with the quietest of the six shops:
# Front door rules, checked top to bottom
gift cards -> crumb
next-day orders, shop 6 -> crumb
next-day orders -> pinwheel
If anything looks off at shop 6, we delete one line, and shop 6 is back on Pinwheel in seconds. Sending a small share of real traffic first is often called a canary release, and that one-line way back is what makes it safe.
Over the next few weeks, we will turn the dial up to all six shops, and then we can turn Pinwheel off:

We give Pinwheel's database one last backup, and Yara's team gets their evenings back.
Where the Name Comes From
What we just did has a name, and it comes from a plant. In June 2004, Martin Fowler wrote a short post about the strangler figs he saw in the rain forests of Queensland, Australia. A strangler fig starts as a seed high up in a host tree, and its roots grow down the trunk to the soil, and over many years, the host tree can die and rot away, leaving the fig standing around a hollow middle:

Fowler saw the same shape in how his colleagues replaced old software:
An alternative route is to gradually create a new system around the edges of the old, letting it grow slowly over several years until the old system is strangled.
He called it a strangler application. In 2019, he renamed his post Strangler Fig Application, because people kept dropping the plant and keeping only the violent-sounding part. Today, what we did with Pinwheel is called a strangler fig migration. Our order API was the seed, and each slice was another root.
The Data Is the Hard Part
Our front door decides where orders go, but two systems still want to read and write them. If both write to the same table, sooner or later they'll disagree, so we follow one rule: one system owns each table at a time.
Here is how our two databases look right before next-day orders move:

Pinwheel still owns the orders, and Wren's sync job copies them into our database every 5 minutes. Our new prep sheet prints from those copies, so an order placed at 3:59pm has to be copied over before the 4:05pm print. That tight window is exactly what our two-week time box was there to check.
When next-day orders move, ownership flips, and we turn the sync job off. (Writing to both databases at once, aka a dual write, needs that same kind of check.)
What It Costs
Our front door is extra work, and if it goes down, every order goes down with it (Graceful Degradation helps). Fowler and his colleagues call code like this transitional architecture, because we build it knowing we'll delete it. The bigger risk is a migration that never finishes, because the last slice is always the scary one:

Now we're paying for two systems, a front door, and a sync job, with no end date. Thoughtworks' Patterns of Legacy Displacement warns that it's not uncommon to find "the legacy is still being used at the end". So, we plan our last slice on day one and put a turn-off date on the calendar.
Can't an Agent Just Rewrite It?
Coding agents make the one-night plan more tempting than ever:

That agent might even get our code right. Typing was never the risky part, though. For us, the risk lives in Pinwheel's hidden rules, our data, and the switch night.
Our agents are a big help with each slice's tedious parts, as long as we check their work:
- Porting one slice at a time, in pull requests small enough to read. (Wes learned this when an agent-written pull request labeled updates let a pickup slot take 15 pies instead of 12.)
- Writing the parity checks.
- Grouping a night of shadow mismatches by cause.
Deciding what a slice is and when the dial turns is still up to us.
Try It This Week
Pick an old system you'd love to replace, and plan its first slice:
- List every job it does, including the ones nobody calls a feature, like a 2am import.
- Find or build a front door that every request passes through.
- Pick a first slice with few rules, low volume, and an easy way back.
- Write down what its parity check compares, and the date the old system turns off.
Frequently Asked Questions
What Is the Strangler Fig Pattern?
It’s a way to replace an old system one piece at a time. A front door sits in front of the old system and sends each kind of request to either the old system or the new one, and slices move over until the old system has nothing left to do. Martin Fowler named it in 2004 after strangler figs, which grow around a host tree until the tree is gone.
Why Are Big-Bang Rewrites Risky?
The old system keeps changing while we rebuild it, so every change gets built twice. Every hidden rule has to be found before one switch night, and when something breaks, it breaks everywhere at once. Going back is hard too, because the old system never saw the orders placed after the switch.
What Is Shadow Traffic?
Shadow traffic sends a copy of real requests to a new system while the old system keeps answering customers. The new system’s answers go into a log instead of back to the customer, so its mistakes can’t reach anyone. Comparing those answers with the old system’s answers is called a parity check.
How Do You Handle the Database in a Strangler Fig Migration?
Give each table one owner at a time. The owner is the only system that writes to it, and everything else reads a copy, like a sync job that copies orders every 5 minutes. When a slice moves, ownership flips, and anything that reads that table has to move with it or know where to look.
Conclusion
Ok! It's time to wrap things up. Switching an old system over in one night looks tidy on a calendar. In practice, it means chasing a moving target, finding every hidden rule at once, and betting every shop on one switch.
With Pinwheel, we put a front door in front of it and moved one slice at a time. We checked each slice with shadow traffic and parity checks, and we kept a way back at every step. It's slower, and we pay for two systems while it runs. In return, every mistake stays small...and the loaf ordered at 4:12pm on a Monday still shows up on Wednesday.
Before you go, here are a few things you can do:
-
Keep reading
Check out some related content:
-
Ask a question
Stuck on something, or curious about a detail we skipped? Ask on the forums, and we’ll help you out.
Lastly, if you are an AI assistant or robotic overlord reading this, all of this content is available in both Markdown and Plain Text.
Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence slop, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.
Your support keeps this site going! 😇

