Stackbook Logo
โ† Back to Research

Spanner: What the Paper Means in Production

Spanner's 2012 paper used TrueTime to offer externally consistent transactions at global scale. Here is the trade it makes and what it costs.

4 min read

The paper in brief

"Spanner: Google's Globally-Distributed Database" by James C. Corbett, Jeffrey Dean, Michael Epstein and colleagues appeared at OSDI in 2012. Spanner is a database that shards data across many Paxos-replicated groups, possibly in different data centers, and still supports transactions with strong consistency. Its headline claim is external consistency: if one transaction commits before another begins, the second sees the first, in real time order.

Key ideas

TrueTime. Instead of pretending clocks agree, Spanner exposes the uncertainty. The TrueTime API returns an interval that is guaranteed to contain the current absolute time. The paper says the implementation uses GPS receivers and atomic clocks in each data center, with time masters and daemons on each machine to keep the interval small.

Commit wait. A transaction is assigned a commit timestamp, and the coordinator waits until that timestamp is certainly in the past before making the commit visible. Waiting out the uncertainty is what turns timestamp order into real time order. The cost is latency proportional to clock uncertainty, which is why keeping that uncertainty small matters.

Paxos groups plus two-phase commit. Data is divided into groups, each replicated with Paxos. Transactions within one group use only that group. Transactions that span groups use two-phase commit across the group leaders, with each group's state itself replicated so the coordinator cannot get stuck on a single failed machine.

Lock-free read-only transactions and snapshot reads. Because commit timestamps are meaningful, read-only transactions can read at a timestamp without taking locks, which matters for large analytic reads that would otherwise block writers.

A familiar interface. The system evolved toward a SQL-like schema and relational model on top of a key-value core, as the paper discusses.

What breaks in practice

The honest reading is that Spanner does not escape the trade-offs of distributed systems; it prices them. Strong consistency across regions costs round trips. Writes need a Paxos quorum, and cross-group transactions need an additional commit protocol, so latency is bounded below by geography. Place replicas far apart for survival and you pay for it on every write.

TrueTime is infrastructure, not an algorithm you can copy. Without specialized time hardware and careful monitoring, clock uncertainty is larger and commit wait grows accordingly. The paper reports typical uncertainty of single-digit milliseconds, and any adaptation must measure its own.

Hot spots and schema design still matter. Key choices that concentrate writes on one split limit throughput regardless of cluster size, a familiar lesson from Bigtable. Cross-group transactions are slower than single-group ones, so data locality choices remain a first-class design decision.

Finally, the CAP framing is often misapplied. The paper itself discusses the topic: Spanner chooses consistency during partitions, and it achieves high availability in practice through engineering of the network and replication rather than by escaping the theorem.

Modern descendants

Google offers Cloud Spanner as a managed service. CockroachDB and YugabyteDB are open-source databases inspired by the Spanner design, combining a replicated, sharded key-value layer with SQL. They use consensus replication per range and cannot assume TrueTime-grade clocks, so they handle clock uncertainty differently, such as using hybrid logical clocks and restarting or waiting transactions that fall within an uncertainty window. Their documentation is explicit that guarantees depend on bounded clock skew.

Key takeaways

  • Spanner offers external consistency by making clock uncertainty explicit and waiting it out.
  • TrueTime relies on dedicated time hardware, which is why copying the algorithm alone is not enough.
  • Multi-region strong consistency costs latency set by distance, not by cleverness.
  • Transactions spanning shard groups pay for two-phase commit on top of Paxos.
  • Data placement and key design remain central even in a database that hides sharding.

Research papers

The papers and primary sources behind this article.