Q24 · What’s your strategy for schema evolution without downtime?

Back to 24 Architecture Questions.

The question is not “run a migration tool”. The axis it turns on: how many versions of the shape must be readable at once. A rolling deploy forces the answer to at least two: the old code and the new code read and write the same data simultaneously, for the whole duration of the release. Schema evolution without downtime is the discipline of designing for that window instead of discovering it.

Expand, migrate, contract During a rolling deploy, code version one and version two both serve traffic, so the data must be readable in both shapes. The protocol is expand to add the new shape, migrate to backfill, and contract to remove the old shape only after the last old reader is gone. FIGURE 24 EXPAND, MIGRATE, CONTRACT Code v1 Code v2 both live during a rolling deploy Expand add the new shape Migrate backfill, dual-shape Contract remove the old shape both shapes written every row speaks both only when v1 is gone at least two versions must be readable at once: the whole strategy is planning for that window

What the answer should contain

The answer to the axis is “two, always”. Old and new code coexist during every rolling deploy, on the same data. Sometimes more than two: slow consumers on a stream, offline mobile clients, partner integrations nobody remembered. The design counts the readers and keeps every shape they still read.

Expand, migrate, contract, never combine. Expand: add the new column or field; old code ignores it, new code writes both. Migrate: backfill in throttled batches, outside the request path. Contract: remove the old shape only after the last old reader is provably gone. The cardinal sin is repurposing or renaming in place: the instant you change a field’s meaning, every old reader is silently wrong.

Make two-version readability cheap with parser discipline. Readers ignore unknown fields (forward compatibility); writers tolerate absent ones and every field has a meaningful default or an explicit “absent”. With those two habits, “additive change” works for databases, JSON, protobuf, and event schemas alike.

Databases migrate online, not at 2 a.m. with an ALTER. Create the new structure, dual-write or use the database’s online schema change tool (create, copy, swap), backfill in the background with load-aware throttling, then drop the old. A blocking ALTER on the hot table is downtime, whatever the maintenance window calls it.

Streams and queues extend the window. A consumer lagging by hours reads shapes the producer retired hours ago. Schema registries with compatibility rules are the enforcement: the registry rejects the change that would strand a live consumer, before it ships.

Prove it in CI. Read old data with new code, write new data with old code, and fail the build on a parse error. Version tolerance is a test, not a vibe.

Ideas worth mentioning out loud

Follow-ups to expect

Red flags in an answer

Sources