Design a Multi-Region Strongly Consistent Database
A Staff-level walkthrough of a Spanner-like database that keeps data externally consistent across regions — using TrueTime (or HLC) to globally order transactions, 2PC layered over per-shard Paxos for cross-region writes, and a multi-phase state machine for zero-downtime schema changes. It trades a few milliseconds of commit-wait latency for real-time transaction ordering at petabyte scale. Follow it top to bottom, or jump to any step.
Scope & ambiguity
“This builds on the KV store question but specifically targets the globally consistent SQL database challenge. The core innovation is using TrueTime (or HLC) to provide external consistency across regions. I’ll focus on how cross-region transactions work with 2PC + Paxos, and how to do online schema changes without downtime.”
Requirements
Deep dives
WHERE STAFF IS WONTrueTime Deep Dive
Cross-Region Write Transaction
Hybrid Logical Clocks (Alternative to TrueTime)
Online Schema Changes
Rollout & evolution
Rollout: Single-region deployment first → add followers in other regions → enable cross-region writes. Migration from existing single-region databases using CDC (Change Data Capture) + dual-write.
Evolution: Year 1: Core database with cross-region transactions. Year 2: SQL query optimizer for distributed execution, change streams (CDC), point-in-time recovery. Year 3: Multi-tenant managed service, automatic sharding recommendations, integration with ML pipelines.
Rubric — Senior vs Staff
Want more breakdowns like this?
Join free early access for upcoming RAG, LLM eval, agents, and AI infrastructure walkthroughs.