10.3.4 · Skill in Maintenance

Migrations and upgrades

Moving to new versions, platforms or providers without breaking the product.

Framework upgrades, database moves and provider changes are large maintenance projects. Incremental approaches, such as running old and new side by side, reduce risk. Deferring them too long turns them into rewrites.

Your status · Migrations and upgrades

Saved in this browser. Sign in to keep it on every device.It colours this skill's tile on your map.

Why it matters for a product engineer

Frameworks, databases and providers all need to change sooner or later: a version reaches end of life, a bill grows, a feature is missing. Each upgrade you skip makes the next one bigger. Product engineers carry the risk, because the product has to keep working, and users should not notice, while everything underneath it moves.

How to do it

  1. Upgrade small and often. One version at a time is a task; five at once is a project.
  2. Run old and new side by side: two versions of a dependency, two providers, two databases.
  3. Move in steps: expand to support both, migrate users or traffic, then remove the old path.
  4. Send a small share of production to the new version first, and compare errors and speed.
  5. Keep a way back at every step until the old path is removed.
  6. Remove the old code when the move is done. A half-finished migration is two systems to maintain.

Common mistakes

  • A long-running branch that never catches up with the main code.
  • Stopping all feature work for an upgrade, which makes the next delay more likely.
  • A switch over in one night, with no way back.
  • Leaving the old path in place “just in case”, for years.

Example

GitHub upgraded its main application from Rails 3.2 to 5.2 between 2017 and 2018. Instead of a long-lived branch, the code could start on several Rails versions, so changes for the next version shipped regularly. Each version went to a share of servers first, and was merged after 30 minutes at peak traffic with no visible impact. Zernio is moving from Vercel to Cloudflare the same way, piece by piece. (Zernio in In practice)

Bars

How long each step of GitHub's Rails upgrade took

  • Rails 3.2 to 4.2A ten-year-old codebase, breaking changes12 months
  • Rails 4.2 to 5.2Smoother upgrades, a team that had learned5 months

The first jump took a year. The second took five months. The lesson GitHub drew: "Upgrade early and upgrade often."

ReportedGitHub blog, 28 Sep 2018

Sources: Upgrading GitHub from Rails 3.2 to 5.2 (GitHub blog) ↗ · Parallel change (Danilo Sato, martinfowler.com) ↗

In practice

Real products

Resources

1
  • articleStart here
    Parallel change ↗
    Danilo Sato (martinfowler.com) · 6 min

    Expand, migrate, contract. The pattern behind changing schemas and APIs without breaking running code.

Tools

1
Tools for Maintenance