Google Spanner Architecture
You'll learn: How Google Spanner achieves the "impossible" — global strong consistency with horizontal scalability using atomic clocks.
The Core Idea
Traditional databases forced you to choose: either strong ACID guarantees (SQL) or massive horizontal scale (NoSQL). Google Spanner breaks this trade-off by synchronizing time across data centers so precisely that it can provide ACID transactions globally while scaling like a NoSQL system.
The secret sauce is TrueTime API backed by atomic clocks and GPS receivers in every Google data center. TrueTime doesn't give you a single timestamp — it gives you a time interval with guaranteed upper and lower bounds. For example, TrueTime might say "the current time is between 10:30:15.001 and 10:30:15.007" with absolute certainty.
How It Works
When Spanner commits a distributed transaction across multiple data centers:
- It assigns a commit timestamp using TrueTime
- It waits out the uncertainty window (typically 7ms) to ensure no other data center could assign an earlier timestamp
- Only then does it mark the transaction as committed
This "commit wait" ensures that even across continents, transaction timestamps respect real-world causality. If Transaction A finishes before Transaction B starts (in real time), Spanner guarantees A's timestamp is earlier than B's.
Think of it like synchronized judges at a global Olympics. Even though they're on different continents, their atomic clocks are so precise that they can all agree on the exact order events happened.
Why It Matters for NewSQL
Spanner proves you can have SQL semantics, ACID guarantees, and global horizontal scaling — if you're willing to invest in specialized hardware (atomic clocks) and accept small commit delays for strong consistency.
Key Takeaway: Google Spanner uses atomic clocks and TrueTime API to achieve globally consistent timestamps, enabling strong ACID guarantees across horizontally scaled, geographically distributed databases.