Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Live Relational Database Migration

Move a continuously used relational workload from SQL Server to PostgreSQL while preserving single-writer correctness, uninterrupted partner reads, and a reversible cutover.

Problem statement

For this exercise, assume an internal service is the sole writer to a 5 TB Microsoft SQL Server database, while a third-party integration requires continuous read-only access through a documented query contract.

Migrate the workload to PostgreSQL without losing acknowledged writes or silently changing the third party's results.

The migration must backfill existing rows while writes continue, capture and apply later changes, compare equivalent reads across both engines after normalizing documented representation differences, and keep the third-party read path available throughout.

SQL Server exposes a supported committed-change feed with stable ordered positions, transaction identity, row mutations, and seven days of retained history.

You may choose log-based change capture, carefully bounded dual writes, transformed backup or log replay, or a combination, but explain the correctness and recovery implications of the approach you select.

Assume 2 billion rows across 200 tables, peaks of 10,000 writes and 50,000 internal reads per second, plus 2,000 third-party reads per second. Complete the online backfill within 72 hours. During shadow operation, 99% of replicated changes should reach PostgreSQL within 60 seconds, and third-party reads should meet a 500 millisecond p95 target with 99.99% monthly availability. One scheduled 30-minute maintenance window may pause internal writes for final cutover, but third-party reads must remain available. After cutover, exactly one database is authoritative for writes; a retry or replay must not apply a logical change twice, and the team must be able to roll back safely until an explicit migration commit point. Under overload, reserve capacity for change capture and target apply and pause snapshot or validation work before source latency, change-feed retention, or third-party read targets become unsafe. Use separate least-privilege credentials for capture, target apply, validation, and partner reads; audit operator, route, and authority changes; and monitor source pressure, retention headroom, migration positions and lag, failures, parity, endpoint health, and rollback readiness.

Design the migration control plane, snapshot and change paths, schema and query compatibility boundary, validation and reconciliation process, read routing, cutover and rollback state machine, failure recovery, and observability.

New product features, active-active writes, a general-purpose database conversion product, and changes to the third party's business behavior are outside scope.

What to build

  1. Operators can resumably backfill existing SQL Server data and continuously apply later source changes to PostgreSQL without a snapshot-to-change gap.
  2. Operators can compare a documented set of equivalent reads across both engines, classify normalized differences, and reconcile unexplained divergence before cutover.
  3. The third-party integration retains an available, authorized read-only contract throughout backfill, shadowing, cutover, and rollback.
  4. Operators can move write and read authority to PostgreSQL through one guarded cutover state machine and roll back safely until an explicit commit point.

At scale

  • For this exercise, assume 5 TB and 2 billion rows across 200 tables, with peaks of 10,000 writes and 50,000 internal reads per second plus 2,000 third-party reads per second.
  • For this exercise, complete the online backfill within 72 hours and make 99% of captured changes visible in PostgreSQL within 60 seconds during shadow operation.
  • For this exercise, third-party reads require 99.99% monthly availability and a 500 millisecond p95 latency target throughout the migration.
  • For this exercise, one 30-minute maintenance window may pause internal writes at cutover; zero acknowledged writes may be lost, replayed logical changes must be idempotent, and rollback remains available until an explicit commit point.
  • For this exercise, the supported committed-change feed retains seven days of stable ordered history; preserve capture and apply headroom by pausing snapshot and validation before source, retention, or partner-read targets become unsafe.