Blog 19 — Google Spanner: Globally Distributed SQL
C
Qubits of DPK
April 7, 2026
Core Case Studies
Core Concept: TrueTime API, Global strong consistency, Multi-region transactions, External consistency
Why SDE-2 Critical: Proves global distribution + strong consistency is possible — banks and payment systems increasingly use Spanner-like DBs
Status: Draft notes ready
Quick Revision
- Problem: Keep SQL transactions globally consistent across regions.
- Core pattern: TrueTime-backed ordering plus Paxos-replicated shards.
- Interview one-liner: Spanner buys strong global consistency by combining distributed systems design with specialized time hardware.
️ What Makes Spanner Unique
javascript
QUBITS OF DPK
Core Concepts
TrueTime API — The Secret Weapon
javascript
QUBITS OF DPK
External Consistency
javascript
QUBITS OF DPK
Architecture
javascript
QUBITS OF DPK
Read Modes
javascript
QUBITS OF DPK
Who Uses Spanner-like Systems
javascript
QUBITS OF DPK
What Spanner Achieved
5 Interview Questions This Blog Unlocks
Q1. Design a global payment system that works across multiple regions
Answer: Use Spanner or CockroachDB. Strong consistency for financial data — can't use eventual consistency for money. TrueTime-based ordering ensures global transaction ordering. Paxos replication for durability. Stale reads for reporting/analytics. Multi-region writes possible with latency tradeoff.
Q2. What is TrueTime and why did Google build it?
Answer: GPS + atomic clocks in every data center. Returns time as an interval [earliest, latest] with max 4ms uncertainty. By waiting for the uncertainty window before committing, transactions get globally ordered timestamps. Eliminates the need for distributed coordination protocols just for time ordering. Only possible with special hardware.
Q3. How is Spanner different from traditional distributed databases?
Answer: Traditional distributed DBs sacrifice consistency for availability (Cassandra, DynamoDB = AP). Spanner provides external consistency (stronger than ACID serializability) while being globally distributed. Achieved via TrueTime — physically synchronized clocks enable global ordering without expensive coordination protocols.
Q4. What is CockroachDB and how does it achieve Spanner-like consistency without atomic clocks?
Answer: CockroachDB uses Hybrid Logical Clock (HLC) instead of TrueTime. HLC combines physical clock + logical counter. Similar external consistency guarantees, slightly more uncertainty. Runs on commodity hardware (no GPS/atomic clocks needed). Open-source Spanner alternative for companies that can't afford Google's infrastructure.
Q5. When would you choose Spanner over Cassandra for a system design?
Answer: Choose Spanner when you need strong consistency AND global distribution: financial systems, payment ledgers, inventory systems where overselling is unacceptable. Choose Cassandra when availability > consistency: social feeds, user activity logs, analytics, any system where eventual consistency is acceptable. Spanner is significantly more expensive.