⚡ ~/naveed Interview Prep
⚡ Portfolio Home ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 1,000+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
← Back to All FinOps & System Design Interview Questions Scenario 52 of 98 in FinOps & System Design
Staff SRE / Principal Database Architect System Design Database Architecture & Migration SRE System Design

Q: Your company operates a legacy on-premises 50 Terabyte PostgreSQL database processing 25,000 transactions per second for payment processing. Management mandates migrating this database to AWS Aurora PostgreSQL. The business allows a maximum downtime maintenance window of only 60 seconds. How do you design and execute this migration with zero data loss and instantaneous rollback capability?

Architectural runbook and failure recovery framework for executing zero-downtime online migration of a mission-critical 50 TB on-premises PostgreSQL database to AWS Aurora PostgreSQL using Debezium CDC, Kafka, and shadow traffic validation.

#System Design #Database Migration #PostgreSQL #Aurora #CDC #Debezium #Zero Downtime
🎙️ Candidate Opening & Architectural Context
"Migrating a 50 TB database via pg_dump/pg_restore requires 48+ hours of offline downtime—unacceptable for high-volume financial services. We engineered a multi-phase online migration pipeline combining physical snapshot seeding, Debezium Change Data Capture (CDC), and dual-writing shadow validation."
Advertisement
⚡ Recommended Practice Lab

Want to master this scenario in a live sandbox? The Linux Foundation's FinOps Certified Practitioner (FOCP) Program covers this exact problem with hands-on terminal drills.

🛠️ Production Runbook & Step-by-Step Resolution

1️⃣

Seed Historical Baseline Data via Physical Backup Streaming

Transfer 50 TB of static data without placing lock contention on the active production database:

  • Seeding Strategy: Provisioned a dedicated read-replica on-premises; executed parallelized physical backup stream using pg_basebackup or pgBackRest directly into AWS S3.
  • Aurora Restore: Restored baseline snapshot into AWS Aurora PostgreSQL cluster with pre-allocated compute instances (db.r6i.16xlarge).
  • LSN Checkpoint: Recorded exact PostgreSQL Log Sequence Number (LSN) marking the completion of the baseline snapshot.
Pro Tip: Streaming backups from an isolated read-replica prevents disk I/O saturation on the active primary transaction processing engine.
2️⃣

Capture & Stream Real-Time Mutations via Debezium & Apache Kafka

Stream transactional inserts, updates, and deletes from the recorded LSN to the cloud:

  • Debezium CDC Connector: Deployed Debezium PostgreSQL connector reading from replication slot using pgoutput plugin starting from the recorded LSN.
  • Kafka Streaming: Streamed WAL mutations into Apache Kafka over a dedicated 10 Gbps AWS Direct Connect private link.
  • JDBC Sink to Aurora: Consumed Kafka events using Kafka Connect JDBC Sink, replaying mutations into Aurora PostgreSQL.
Pro Tip: Replication slots retain WAL logs on the source database until confirmed by Debezium; carefully monitor disk space to prevent WAL directory exhaustion.
3️⃣

Continuous Data Consistency Validation & Shadow Traffic Reads

Mathematically verify data integrity before initiating the cutover:

  • Checksum Reconciliation: Executed automated chunked hashing algorithms comparing rows between on-premises and Aurora to guarantee 100% data parity.
  • Shadow Read Traffic: Deployed Envoy proxy to duplicate 10% -> 50% -> 100% of read traffic to Aurora, validating query plan performance and buffer pool warming under production load.
Pro Tip: Shadow read traffic warms the Aurora buffer cache, preventing devastating query latency spikes upon traffic cutover.
4️⃣

Execute 45-Second Cutover with Reverse CDC Fallback

Switch application connections and guarantee instant rollback safety:

  • Reverse Replication Setup: Pre-configured Debezium CDC running in reverse (Aurora -> on-premises) in standby mode.
  • The 45-Second Window: Set on-premises DB to read-only; waited 12 seconds for Kafka consumer lag to reach 0; updated application DNS / connection pool endpoints to Aurora; opened writes on Aurora.
  • Rollback Safety: Reverse CDC immediately streams Aurora writes back to on-premises. If an unexpected critical issue arose in hour 1, switching back to on-premises required zero data loss.
Pro Tip: Establishing reverse CDC before opening writes on the target database provides a true safety net, eliminating career-ending point-of-no-return migration risks.
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Zero-downtime multi-terabyte database migration requires baseline snapshot seeding, Debezium WAL streaming to catch up, shadow read traffic for cache warming, and reverse CDC for zero-risk rollback."
⚡ 60-Second Elevator Pitch Talking Points
  • Seed initial 50 TB baseline from an isolated read-replica using pgBackRest to AWS S3.
  • Deploy Debezium CDC and Kafka over Direct Connect to stream real-time mutations with sub-second lag.
  • Run automated hash reconciliation and shadow read queries to warm Aurora buffer pools.
  • Execute cutover in under 45 seconds with reverse CDC active for immediate zero-data-loss rollback.
Advertisement
Want more FinOps & System Design scenarios?
Explore our complete collection of scenario-based FinOps & System Design interview runbooks.
Browse All FinOps & System Design Questions →