Back to Articles
Database

Distributed Transactions in Spanner: Unpacking TrueTime

August 1, 202612 min read

Achieving strong consistency in a globally distributed database while maintaining high availability and low latency has historically been considered an impossible engineering feat, bounded by the CAP theorem. Relational databases traditionally rely on single-node bottlenecks for sequence generation and locking, making them unsuitable for multi-region scale. To build transactional systems that span continents without compromising on data integrity, engineers must understand the paradigms of external consistency and globally synchronized clocks.

Our deep dive into Spanner’s architecture reveals how it orchestrates strictly serializable distributed transactions utilizing a combination of Paxos consensus groups and the TrueTime API. TrueTime leverages GPS and atomic clocks to provide bounds on clock uncertainty, allowing Spanner to assign globally meaningful commit timestamps without requiring centralized communication. During a distributed mutation, Spanner employs a highly optimized Two-Phase Commit (2PC) protocol across participating Paxos leaders, utilizing these timestamp bounds to ensure that no transaction reads stale data or violates causal ordering.

Migrating our core financial ledger to this architecture allowed us to execute multi-continent transactions in under 15 milliseconds while guaranteeing strict serializability. Understanding Spanner's elegant use of hardware-assisted time bounding has profoundly shifted our perspective on database engineering, proving that global consistency can be achieved without catastrophic performance penalties.

Thanks for reading. Browse more articles →