IntermediateSeniorData Architecture & Consistency55 minutesComplete public sample

SDV-009

Migrate a multi-terabyte database without downtime or wishful dual writes

Plan snapshot, change capture, validation, cutover, rollback, and cleanup for a live database whose write rate and long tail make naïve copying unsafe.

Data MigrationZero DowntimeBackfillsReconciliation

Interview prompt

Problem context

A 12 TB transactional database with 90k writes per second must move to a new storage engine. The application cannot pause writes for more than seconds, schemas differ, and some rows have years of history. Design a repeatable migration that proves correctness and can be aborted safely.

Skills being evaluated

online data migrationchange data captureverificationcutover planning
A reasoning guide, not a memorized architecture

Use the sequence below to surface constraints, choose boundaries, test failure behavior, and defend trade-offs. Concrete numbers are interview assumptions, not claims about a real production system.

01

Clarify the decision

  • Define the invariant set, tolerated cutover pause, rollback window, data retention, and whether the new engine changes transaction semantics. Identify tables and operations that can migrate independently rather than treating 12 TB as one atomic move.
02

Establish scale assumptions

  • Assume 12 TB, 90k writes/second, 30% annual growth, and a copy channel capped below the bandwidth that would hurt production. Estimate snapshot duration, CDC log retention, transform throughput, and the lag required before cutover.
03

Functional and non-functional requirements

  • No acknowledged write may disappear, transformed data must satisfy business invariants, customer impact must stay within the SLO, and every phase must be resumable and auditable. Cleanup waits until the rollback window expires.
04

High-level architecture

  • Take a consistent source snapshot at log position L, bulk-copy through idempotent transformers, and concurrently stream changes after L through CDC. A validation service compares counts, checksums, invariants, and sampled query results; a migration controller owns phases and gates.

A single-authority snapshot-and-log pipeline with independent validation and an explicit gated cutover.

Authority
Source Database
only writer pre-cutover
Movement
Range Backfill
checkpointed copy
CDC Stream
changes after L
Proof
Validator
checksums + invariants
Migration Controller
gates + audit
Destination
New Database
shadow then authority
ClientEdge / GatewayServiceCacheDatastoreQueue / StreamML / GPUExternal
05

Data model and flow

  • Backfill in stable key ranges with checkpoints and rate limits. CDC events carry source position and operation identity, the destination upserts idempotently, and per-range high-water marks let validators know when snapshot plus deltas are complete.
06

Consistency and transaction boundaries

  • Keep the source as the only write authority until cutover; avoid application dual writes where partial success creates ambiguity. During a brief final drain, stop new writes, wait for CDC lag to reach zero, record the terminal source position, switch routing, and reopen.
07

Failure modes and recovery

  • Workers retry ranges idempotently, poison transformations quarantine records without hiding the gap, and CDC retention alarms well before data expires. Before cutover, rollback means discard or reset destination state; after cutover, rollback requires reverse replication or a clearly bounded source freeze strategy.
08

Security and privacy

  • Encrypt transfer and temporary files, preserve tenant and row-level authorization semantics, and prevent logs from leaking sensitive values. Ensure the destination inherits deletion, residency, retention, and audit obligations before production traffic.
09

Observability and SLOs

  • Track copied bytes and rows, range retries, transform errors, CDC lag, invariant mismatches, destination query divergence, source impact, and cutover gates. Publish a migration dashboard with go/no-go owners and automated thresholds.
10

Capacity and cost

  • Budget temporary double storage, CDC retention, validation reads, and network egress. Throttle against production latency and schedule large scans on replicas when their lag and failover role allow it.
11

Alternatives and trade-offs

  • Application dual writes reduce cutover pause but create a two-system correctness problem on every write. Snapshot plus CDC keeps one authority and concentrates complexity in a recoverable pipeline; accept a bounded drain if it materially simplifies proof.
12

Evolution and migration

  • Use expand-contract schema changes, migrate low-risk tables or tenants first, shadow reads and compare, then canary a small traffic slice. After full cutover, retain source read-only through the rollback window, reconcile again, then remove CDC and old schema deliberately.
13

What Staff and Principal candidates should emphasize

  • A strong answer treats migration as a state machine with evidence, not a copy command. Name the authority at every phase, the exact cutover condition, how mismatches are repaired, and why rollback differs before and after writes begin on the destination.

Decision trade-offs

Write capture

Option A

Database log-based CDC

Option B

Application dual writes

Recommendation:Prefer log-based CDC when available because the source remains authoritative and application failures cannot silently split writes.

Final cutover

Option A

Seconds-long write drain

Option B

No pause with bidirectional replication

Recommendation:Take the bounded drain if the SLO allows it; bidirectional replication is justified only when zero pause is worth a much larger conflict surface.

Follow-up interview questions

  1. 01How do you bootstrap CDC without missing writes between snapshot and stream start?
  2. 02What happens if the migration runs longer than source log retention?
  3. 03How do you roll back after the destination has accepted new writes?
  4. 04Which validation signals are strong enough for the final go/no-go decision?

Common weak answers and mistakes

  1. 01Copying rows and then starting CDC without a shared snapshot position.
  2. 02Calling dual writes reliable without modeling each partial-success permutation.
  3. 03Validating only row counts and missing transformation or invariant errors.
  4. 04Dropping the source immediately after cutover and making rollback fictional.

Interviewer evaluation rubric

Weak

Proposes an export/import or dual write but cannot identify the authoritative system and loss-free handoff.

Solid

Uses snapshot plus CDC, checkpointed workers, lag monitoring, validation, and a bounded cutover.

Strong

Defines log positions, invariant proof, stateful gates, source protection, canary reads, and different rollback phases.

Exceptional

Decomposes migration risk by domain, automates evidence and abort criteria, and accounts for security, retention, cost, and operator ownership.