Splitting the monolith
Payments live inside a monolith, in tables the rest of the application joins against freely. The business wants payments extracted into a service with its own store. Nothing may stop, every step must be reversible, and the sheet already has the system as it exists today.
Envelope50k payment transactions/minute · one shared database · zero downtime
What the design must do
- All traffic passes through a routing layer that can move one route at a time
- The extracted service owns its own datastore
- The extracted service never reads the old database directly
- The monolith keeps seeing payment state while both run
- Any step can be reversed by changing configuration, not by deploying
What is already built
This one is brownfield: the system exists, and the exercise is changing it rather than drawing it from nothing. You start with Client, Load Balancer, App Service, Legacy Store, Cache already wired up.
The worked envelope
Assumed. 50k payment transactions a minute at peak. The monolith's database is 4 TB, of which the payment tables are about 600 GB. Backfill is throttled to protect the live system.
| Payment writes | 50k ÷ 60 ≈ 833/s, peak ~2,500/s |
| Payment data | 600 GB of a 4 TB database |
| Backfill | 600 GB at a throttled 20 MB/s ≈ 8.3 hours |
| CDC lag budget | under 5 s, or shadow-read mismatches are just lag |
| Route flip | a config change, ~30 s to take effect fleet-wide |
| Dual-run | weeks, not days — long enough to see a month-end |
What the numbers decide. Look at the first row and notice what is missing. Eight hundred writes a second is a single unremarkable database. There is no capacity problem here, no sharding decision, no cache to size. Every other lab in this tier is an argument about scale; this one has no scale argument at all, and if you catch yourself drawing for throughput you have answered a question nobody asked.
What the numbers actually constrain is reversibility. The backfill takes a third of a day, so it runs while the system serves traffic and must be throttled to something the live database will not notice. The route flip takes thirty seconds, which is the entire reason the facade exists — it makes "undo" a configuration change rather than an emergency deploy. And the dual-run is measured in weeks because the failures you are hunting are the ones that only appear at month-end close, on the refund path, in the reconciliation job nobody remembered.
The last row is the one that gets negotiated down in real projects, and it is the one that should not be. Everything else on this sheet is machinery for buying time to find out you were wrong.
The decisions, and what each one costs
A routing layer in front of everything, before any code is extracted
- Because
- Moving a route has to be a configuration change or the migration has no undo — and the facade must be in place while it still does nothing, so that installing it is a separate, boring, independently reversible step
- The cost
- An extra hop on every request forever, and a component that is now a single point of failure for traffic that used to reach the monolith directly
- Rejected
- Switching traffic at the load balancer per deploy, which couples every route move to a release and makes rollback a deploy under incident pressure
The extracted service gets its own database, and the old one stays where it is
- Because
- The shared database is the coupling — as long as two deployables join the same tables, neither schema can change and the split has bought nothing but operational overhead
- The cost
- The joins the monolith used to do for free become API calls or duplicated data, and there is no longer a transaction spanning payments and orders
- Rejected
- A shared schema with the new service reading the old tables, which demos as a working extraction and leaves every constraint that motivated the project
Change data capture from the legacy store into the new service, not a dual write
- Because
- The backfill and the ongoing sync are the same mechanism, ordered and complete including deletes, and it works without changing monolith code — which matters because the monolith is the thing you are trying not to touch
- The cost
- A replication slot whose lag is now an alert on the legacy primary, and coupling to the old physical schema for as long as the dual-run lasts (Lesson 7.06)
- Rejected
- Dual writes from the monolith, which need the code change you were avoiding and diverge silently the first time one of the two writes fails
Shadow reads before any read is flipped, mismatches logged and driven to zero
- Because
- Every migration has undocumented behaviour in it — a rounding rule, a null treated as zero, an ordering nobody wrote down — and this is the step where production tells you what it is, for free, before a user sees it
- The cost
- Both systems serve every read during the shadow period, so you pay double the read cost and write a mismatch pipeline you will throw away
- Rejected
- Flipping reads at 1% and watching error rates, which finds the crashes and none of the quietly wrong answers
Flip reads by route and percentage, and leave writes on the old path longest
- Because
- A wrong read is an incident; a wrong write is a corruption you may not be able to reconstruct, so the reversible half moves first and the irreversible half moves last, with the most soak time behind it
- The cost
- A long window where the system is genuinely two systems, with both operational burdens and a mental model every on-call engineer has to hold
- Rejected
- One cutover of reads and writes together at a quiet hour, which is the big-bang rewrite compressed into a single night
Components in the reference design
- Client
- Browser or mobile app
- Load Balancer
- L7 routing, TLS termination, health checks
- API Gateway
- Auth, routing, quota enforcement
- App Service
- Stateless business logic
- Legacy Store
- The existing shared database, with everyone already in it
- New Service
- A capability being carved out, running alongside the system it is leaving
- SQL DB
- Relational, ACID, joins
- Event Log
- Kafka-style, ordered, replayable
What not to draw
- New Service → Legacy Store — The new service reading the old database is the shared-database coupling you were paid to remove. It makes the extraction cosmetic: the schema still cannot change, the monolith still cannot be deleted, and you now run two deployables instead of one for no benefit.
- Load Balancer → App Service — Any path that reaches the monolith without passing the routing layer is a route you cannot move, cannot flag, and cannot roll back without a deploy. The facade only works if everything goes through it.
The reference design
The sheet started full, and that is the lesson. Every other lab in this tier begins with an empty canvas and a scale target. This one begins with a system that works, that people depend on, and that you may not stop — and the skill being tested is sequencing, not drawing. The end-state topology here is not clever. Getting to it without an outage is the entire job.
Why the facade goes in first. The routing layer is installed while it changes nothing: every route still points at the monolith, the deploy is boring, and it can be reverted on its own. That is deliberate. If the facade arrives in the same change as the first moved route, then a problem during that move has two possible causes and you will be diagnosing under pressure. Strangler fig works because each step has one variable.
The order is fixed, and skipping steps is how migrations become incidents. Facade in place, then the new service deployed and dark, then CDC populating its store, then shadow reads until mismatches are explained, then reads flipped by percentage, then writes, then — after weeks, not days — the old path deleted. Lesson 14.03 gives the same choreography for a datastore; this lab is that choreography applied to a capability, which is why both the strangler and the dual-write sequence appear on one sheet.
What you give up permanently. The transaction that used to wrap "record the payment and update the order" spans two databases now, and no amount of design brings it back. That is the moment to reach for the saga and the outbox from Lesson 6.05, and the moment to be honest in the design doc that the system has traded a guarantee for independence. A reviewer who does not see that trade written down is right to be suspicious.
The deletion is a real step with a real date. Migrations that stop at ninety percent are the most common failure of this pattern, and they are the worst outcome available: two systems, two on-call surfaces, the old schema still frozen because something might still read it, and none of the benefit. Put the deletion on the plan, with an owner, before starting.
What changes at 10×. Nothing structural, and everything about duration. At half a million transactions a minute the backfill runs for days rather than hours and has to be resumable, the CDC pipeline needs its own capacity plan, and the dual-run window costs enough that somebody will propose shortening it. That proposal is the risk. The correct answer at any scale is that the soak time is set by how long it takes for the rare paths to occur, not by how much the duplicate infrastructure costs.