Preparing your design workspace

Loading the problem and your latest saved attempt…

Design Zero-Downtime Database Migration

Move a live application to a new database schema or cluster while preserving writes, correctness, and rollback.

Problem statement

For this exercise, assume the following practice scope. Design a zero-downtime database migration for a live multi-tenant application moving from one relational cluster and schema version to another. Reads and writes must remain available throughout; no planned write pause is allowed.

The source is initially authoritative. A consistent snapshot backfills historical rows while change-data capture replays later mutations in per-key order. Application releases use expand-and-contract compatibility so old and new binaries can coexist.

Before cutover, the system verifies row, aggregate, and business invariants under a stable watermark. Traffic shifts gradually to target reads and then target writes under one activation generation; rollback before the irreversible boundary returns traffic to the source without losing accepted writes.

Design schema evolution, snapshot and CDC, dual compatibility, validation, cutover, rollback, tenant isolation, monitoring, and cleanup. Cross-engine query optimization and redesigning the product data model are outside scope.

What to build

  1. Keep reads and writes available without a planned write pause.
  2. Backfill a consistent snapshot and replay later source mutations exactly once logically.
  3. Support old and new application versions during expand-and-contract schema evolution.
  4. Validate target correctness at a stable watermark before traffic shifts.
  5. Cut over and roll back through one generation-fenced authority with an explicit irreversible boundary.

At scale

  • Assume 20 TB of data, 50,000 writes per second, and 200,000 reads per second.
  • Migration may run for seven days while CDC lag should remain below 30 seconds p99.
  • No acknowledged source write may be lost; transient duplicate application is tolerated only if idempotently collapsed.
  • A worker, zone, or target-cluster failure must pause or resume migration without requiring a write outage.