100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
API Design & Best Practices
34 minintermediate

Migration and Rewrite Strategies

Every API old enough to matter eventually needs a migration: a new data model that doesn't fit the old shape, a monolith split into services, a legacy system finally being retired after years of everyone agreeing it should be. The instinct under pressure is to plan the destination carefully and treat getting there as a footnote — build the new system right, then do a cutover weekend. That instinct is exactly backwards for anything with real traffic and real consumers, because the cutover weekend is where almost all migration failures actually happen: a big-bang switch has no partial-failure state, no way to verify the new system handles real traffic correctly before it's the only system handling it, and no calm path back if something's wrong.

The alternative this lesson builds toward isn't more caution for its own sake — it's a different shape of risk entirely. Instead of one large, irreversible decision made at 2 a.m. on cutover night, a well-run migration is a long sequence of small, individually reversible decisions, each one verified against real production behavior before the next one depends on it. The new system runs alongside the old one, proving itself on real traffic while the old one keeps serving, and the actual cutover — when it finally happens — is almost anticlimactic, because every real risk was already found and fixed while the old system was still there as a safety net.

This connects directly to versioning and deprecation, covered earlier in this course, but a migration is a bigger commitment than a routine version bump: it usually touches every consumer, takes months, and has real organizational cost if it stalls halfway. What follows is a set of concrete techniques — the strangler fig pattern, shadow traffic, expand-contract schema changes, and a disciplined rollback plan — for making that commitment survive contact with a production system that, inconveniently, has to keep working the entire time you're changing it underneath.

Analogy🏏Cricket
🏏 Think of it like cricket: A groundskeeper relaying an entire outfield ahead of a major tournament doesn't dig up the whole ground the week before the first match and hope the new turf has rooted in time — that's a bet the entire tournament's opening fixture rides on, with no fallback if the grass hasn't taken by matchday. A well-run relay is done in sections, over a much longer window, with each newly laid section tested under actual match-like conditions — fielders training on it, a ball rolled across it to check the bounce — before the next section is touched, while the rest of the outfield keeps hosting real training sessions the whole time. If a section doesn't take root properly, it's caught and re-laid while there's still a section of old, reliable turf nearby to fall back on for that week's training, not discovered for the first time when eleven fielders are sprinting across it during a televised match. Just as the groundskeeper proves each new section under real conditions before depending on it fully, a migration proves each new component under real production traffic before depending on it fully. Just as relaying the whole ground at once, all at the deadline, turns one bad section into a tournament-wide crisis with no fallback, a big-bang cutover turns one undiscovered bug into an outage with no fallback either. The insight is that the actual risk in a large change isn't the change itself — it's discovering a problem for the first time at the exact moment you no longer have anything to fall back on, and the entire discipline of a good migration is arranging things so every problem gets found while a fallback still exists.
Lesson 33 of 35
0% complete