Whitepapers
15 items
15 items
The first system to achieve external consistency at global scale using synchronized clocks and TrueTime
Spanner is Google's globally distributed database that provides external consistency (linearizability) for distributed transactions while maintaining high availability. The breakthrough is TrueTime—an API that exposes clock uncertainty, enabling Spanner to order transactions globally without communication. By waiting out clock uncertainty before committing, Spanner guarantees that if transaction T1 commits before T2 starts, T1's timestamp is less than T2's. This seemingly simple property enables globally consistent reads and true ACID transactions across continents.
Instead of pretending clocks are synchronized (they're not), TrueTime exposes uncertainty as an interval [earliest, latest]. Spanner waits out this uncertainty before committing, guaranteeing correct ordering. GPS and atomic clocks keep uncertainty typically under 7ms.
Traditional distributed transactions require coordination (2PC) which adds latency. Spanner's commit-wait protocol uses time instead of communication—if you wait long enough, you're guaranteed to be after all concurrent transactions.
Any read at a past timestamp can execute on any replica without locks or coordination. The timestamp guarantees a consistent snapshot. This enables fast, globally distributed read replicas.
By 2012, Google had massive global systems built on Bigtable—but Bigtable had limitations:
No cross-row transactions: Updating multiple rows atomically required complex application logic No strong consistency for reads: Applications dealt with eventual consistency or added synchronization No SQL interface: Developers wrote custom MapReduce jobs for queries
Meanwhile, traditional SQL databases couldn't scale globally:
Single-master bottleneck: All writes go to one location Replication lag: Read replicas serve stale data 2PC across datacenters: Distributed transactions have unacceptable latency
Google needed a system that combined: - Global distribution (like Bigtable) - Strong consistency (like single-node SQL) - ACID transactions across shards
The fundamental challenge is clock synchronization. In a single datacenter, we can use a single clock or tightly synchronized clocks. Globally, clocks drift. Network delays vary. How do you order transactions across continents?
Previous approaches: - Logical clocks (Lamport): Provide causality but not real-time ordering - Vector clocks: Track causality precisely but don't map to wall-clock time - NTP: Reduces drift but can't bound uncertainty reliably
Spanner's answer: TrueTime—a novel API that exposes clock uncertainty and uses specialized hardware (GPS + atomic clocks) to minimize it.