LOAD-BEARINGfree
High-level designTier 14 · unit 3 of 12 · 13 min read

Migrating a live system

Here's the truth about real engineering that coursework hides: nobody designs on a blank page. There is always an existing system, currently serving traffic, that cannot stop — and the actual staff-level skill is changing it live. Swapping the engine mid-flight, with passengers aboard, is a learnable procedure. Two patterns cover nearly every migration you'll ever run:

Strangler fig: replacing a system route by route

Named after the vine that grows around a tree, slowly taking over until the tree inside is gone. For replacing a legacy service: put a routing layer in front of the old system, then move one endpoint at a time to the new implementation. /search goes new this month; everything else still hits legacy. Next month, two more routes. The old system shrinks call by call until nothing reaches it — then it's deleted, ceremonially.

Why this beats the rewrite-and-cutover it replaces: each route is individually reversible (new /search misbehaves? Flip that one route back — a config change, not a rollback of a launch); risk arrives in slices, not one big-bang night; and the team learns the legacy system's undocumented surprises — and there are always undocumented surprises — a slice at a time, while the blast radius is one endpoint. The grand rewrite that launches all at once is the most reliably fatal project shape in software; the strangler fig is its antidote.

Dual write, then verify: moving a datastore

Changing databases under a live product — Postgres to Cassandra, resharding, v1 schema to v2 — has a canonical choreography. The order matters; skipping steps is how migrations become incidents:

1  DUAL WRITE   every write goes to old AND new; reads stay on old
2  BACKFILL     copy history into new, throttled batches; verify counts
3  SHADOW READ  read BOTH, serve old, log every mismatch
4  FLIP READS   behind a flag: 1% → 10% → 100% to new
5  STOP OLD     writes off, then delete — after a decent mourning period

Step 3 deserves its own paragraph, because it's the step teams skip and then regret. Shadow reads run both systems against real production traffic and diff the answers, while users still see only the trusted old system — mismatches are logged, not served. This is where reality confesses: the timezone handling that differs, the null the new schema treats differently, the ordering assumption nobody documented. Every migration has these; the only question is whether you find them in mismatch logs (free) or in production incidents (expensive). Flip reads only when the mismatch rate is ~zero and you can explain the residue.

Notice the deep structure: it's Tier 9's expand–migrate–contract, scaled from one column to a whole datastore — and every single step is reversible until the final delete, which is why step 5 waits weeks after step 4, and why backups exist even then. (One implementation note: dual-writing from application code can itself miss writes when one store errors — for high-stakes moves, drive the second store from the first one's change stream or a Tier 6 outbox, so the two can't silently diverge.)

Migration hygiene, briefly

Feature flags gate every switch (Tier 9 — rollback in seconds); throttle the backfill (an unthrottled copy job is a self-inflicted DDoS on the live database — batch, sleep, watch replica lag); and write the rollback procedure before you need it, because deciding how to reverse under incident adrenaline at 3am produces bad decisions, and the migration that "couldn't need" a rollback plan is the one that will.

The trap

The Big Rewrite: freeze the old system, build the new one "properly" for eighteen months, cut over one glorious weekend. It fails on schedule, every time, for structural reasons: the old system doesn't freeze (business continues, so you're chasing a moving target), the new system meets production's undocumented edge cases all at once on cutover night, and by month twelve the rewrite is politically too big to fail and too broken to ship. Route by route, flagged, shadow-verified, reversible — boring is the strategy.

Going deeper

  • Refactoring Databases: Evolutionary Database Design Ambler & Sadalage, 2006
    Expand–migrate–contract worked through at length, with the migration patterns catalogued.
  • Strangler Fig Application Martin Fowler, 2004
    The short essay that named the pattern.