Skip to content

PAPER EXPLAINED

Spanner: Google’s Globally-Distributed Database

AdvancedAbout 45 min to read the paper

TL;DR

Spanner is Google's globally replicated database. It gives transactions real-time-ordered commit timestamps by using TrueTime, a clock API that reports bounded uncertainty, and by waiting out that uncertainty before committing.

What problem does Spanner solve?

Google applications wanted strong consistency, schematized tables, and general transactions across wide-area replicas. Bigtable offered only eventually consistent cross-datacenter replication and no cross-row transactions. Megastore had synchronous replication but poor write throughput. Ordering distributed transactions consistently with real time at global scale is hard because machines' clocks disagree. Without a trustworthy notion of time, consistent snapshots, lock-free reads, and atomic schema changes across many servers are difficult to provide.

The core idea

Make clock uncertainty explicit. TrueTime answers "what time is it?" with an interval guaranteed to contain the true time, kept small using GPS and atomic clock references. Spanner gives each transaction a commit timestamp at or after the latest possible current time. It then waits until that timestamp has definitely passed before revealing the result. As a result, timestamps respect real-time order across the whole system. Replicas can serve consistent reads at any timestamp they are known to be up to date for, without locks.

IN THE AUTHORS’ WORDS

“If the uncertainty is large, Spanner slows down to wait out that uncertainty.”

Spanner: Google’s Globally-Distributed Database, p. 2

“One aspect of our design stands out: the linchpin of Spanner’s feature set is TrueTime.”

Spanner: Google’s Globally-Distributed Database, p. 13

“As a community, we should no longer depend on loosely synchronized clocks and weak time APIs in designing distributed algorithms.”

Spanner: Google’s Globally-Distributed Database, p. 13

How Spanner works

  1. Data lives in tablets on spanservers. Each tablet is replicated by a Paxos state machine, forming a Paxos group with a long-lived leader holding a timed lease. The leader keeps a lock table for two-phase locking and a transaction manager for cross-group transactions.
  2. Keys sharing a prefix form directories, the unit of placement and movement between Paxos groups. Schemas declare table hierarchies with INTERLEAVE IN so related rows stay together.
  3. TrueTime returns an interval [earliest, latest]. Time masters with GPS or atomic clocks serve per-machine daemons, which reject outliers. Uncertainty typically varies from about 1 to 7 ms over each poll interval.
  4. Paxos leader leases are kept disjoint, and each leader assigns timestamps only within its lease. This makes timestamps monotonic within a group even across leader changes.
  5. For read-write transactions, participants prepare and log prepare timestamps. The coordinator chooses a commit timestamp at least as large as all of them and above TT.now().latest. It then waits until TT.after(s) before committing (commit wait).
  6. Each replica tracks a safe time, the highest timestamp it is up to date for. Read-only transactions and snapshot reads pick a timestamp and read lock-free at any sufficiently up-to-date replica.
  7. Schema changes are assigned a future timestamp registered during prepare. Operations before that time proceed, while later ones wait, so large schema changes avoid blocking all activity.

Results

Microbenchmarks show commit wait of about 5ms and Paxos latency of about 9ms. Snapshot-read throughput rises almost linearly with replicas. Two-phase commit stays reasonable up to about 50 participants, and latency rises noticeably at 100. Killing the leader zone without warning briefly drops reads to near zero, with recovery in about 10 seconds tied to lease length; a graceful handoff costs around 3-4%. TrueTime uncertainty is generally small but has tail spikes, for example during time-master maintenance. Bad CPUs were 6 times more likely than bad clocks. In F1, mean latencies were 8.7ms for reads, 72.3ms for single-site commits, and 103.0ms for multi-site commits. Caveat: the benchmarks used timeshared machines, datacenters less than 1ms apart, and in-memory reads.

Limitations and what came later

  • Correctness relies on TrueTime's bound holding, such as local clock drift staying within 200us/sec. Write latency includes commit wait that grows with the uncertainty ε.
  • Paxos leader leases default to 10 seconds, so a hard leader failure can reduce availability for roughly that long.
  • Node-local data structures were designed for key-value access and perform relatively poorly on complex SQL queries.
  • At the time of writing, secondary indexes, in-Paxos configuration changes, and automatic load-based resharding were not yet supported. Paxos writes were also logged twice.
  • The paper leaves most TrueTime implementation details and the query language for elsewhere. Microbenchmarks used close-together datacenters.

Why Spanner matters

Spanner shows that a widely distributed system can offer externally consistent transactions if it treats clock uncertainty as a first-class, bounded quantity rather than assuming clocks agree. That one abstraction supports lock-free consistent reads, snapshots in the past, and atomic schema changes. The paper also argues that tighter clock bounds directly lower the cost of strong semantics, which reframes time synchronization as a design tool for distributed algorithms.

Spanner is a clear case study in using knowledge of time to build a database that is both globally replicated and strongly consistent. Its central move is simple to state: do not pretend clocks are exact. The TrueTime API returns an interval that is guaranteed to contain the real time, and the system waits out that uncertainty when correctness requires it. From this one idea the paper derives several features. Transactions get commit timestamps that respect real-time order. Read-only transactions take no locks. Consistent snapshot reads in the past are possible. Schema changes can be atomic across a very large deployment. The paper connects the design to Google's practical pressures, including complaints about Bigtable and Megastore and a painful manual MySQL resharding for the F1 advertising backend. It also includes short proofs of its invariants alongside measured costs. Readers learn both the mechanism and the price: commit wait, leader-lease recovery time, and how clock uncertainty behaves in production.

Before you read

Who it’s for

Engineers and students interested in distributed databases, replication, and transaction processing. It suits anyone who wants to see how consensus, two-phase commit, locking, and bounded clock uncertainty fit together in one deployed system.

What to know first

  • Basic idea of Paxos or replicated state machines
  • Two-phase commit across multiple participants
  • Two-phase locking and deadlock avoidance
  • Snapshot isolation and multi-version data
  • Linearizability / external consistency as correctness notions
  • Sharding and replication in key-value stores like Bigtable

Glossary

TrueTime
Spanner's time API. It returns an interval guaranteed to contain the true current time, plus helpers that report whether a time has definitely passed or definitely not arrived.
External consistency
If transaction T1 commits before T2 starts, T1's commit timestamp is smaller than T2's. The paper treats this as equivalent to linearizability.
Commit wait
The coordinator waits until its chosen commit timestamp has definitely passed according to TrueTime before letting anyone see the transaction's writes.
Paxos group
The set of replicas of a tablet kept consistent by a Paxos state machine, with a lease-holding leader that handles writes and locking.
Directory
A set of contiguous keys sharing a prefix. It is the unit of data placement and of movement between Paxos groups.
Safe time (t_safe)
The highest timestamp at which a replica is known to be up to date. A read at time t can be served if t is at most the safe time.
Leader lease
A timed grant (10 seconds by default) giving a Paxos leader authority. Leases of different leaders in a group never overlap.
Snapshot read
A lock-free read of data as of a past timestamp, either specified by the client or chosen within a staleness bound.
Armageddon master
A TrueTime time master equipped with an atomic clock rather than GPS, providing a reference with different failure modes.

What to pay attention to

  • The TrueTime API in Table 1 (p.5): time is returned as an interval [earliest, latest], not a single number.
  • The Start and Commit Wait rules and the five-line proof on p.7. This is the heart of external consistency.
  • Why the expected commit wait is at least twice the average uncertainty, and how it overlaps with Paxos communication (p.8).
  • Safe time (t_safe) and how prepared-but-uncommitted transactions hold it back (p.7). The refinements on p.9 relax this.
  • The disjointness invariant for Paxos leader leases (p.6, Appendix p.14), which underpins timestamp monotonicity across leaders.
  • The experimental setup caveats on p.9: timeshared machines, datacenters less than 1ms apart, and in-memory reads.
  • The availability experiment (Figure 5, p.10) and how the 10-second lease length shapes recovery.
  • How directories and INTERLEAVE IN let applications control locality (pp.3-5).

You can skip it if… Skip if you only need a high-level summary of what Spanner offers, or if you are looking for detail on Spanner's SQL query language or TrueTime's internal implementation. The paper explicitly leaves both mostly undescribed.

Questions to keep in mind

  • Why would a correct system ever deliberately wait before making a commit visible, and what exactly is being waited for?
  • How does exposing clock uncertainty differ from assuming loosely synchronized clocks, and what does that buy Spanner?
  • What prevents two Paxos leaders in the same group from assigning overlapping or out-of-order timestamps?
  • Why can read-only transactions and snapshot reads proceed without locks, and when must they still block?
  • Which reported costs (commit wait, lease-based recovery, 2PC fan-out) would matter most for an application spread across distant continents?

Spanner quiz: check your understanding

1. What does TT.now() return, and what does it guarantee?

Show the answer

It returns a TTinterval [earliest, latest]. The interval is guaranteed to contain the absolute time at which TT.now() was invoked. The instantaneous error bound ε is half the interval's width.

2. What is commit wait and why is it needed?

Show the answer

The coordinator leader picks a commit timestamp s no less than TT.now().latest. It then keeps clients from seeing the transaction's data until TT.after(s) is true. This guarantees s is less than the absolute commit time. Combined with the Start rule, it ensures a transaction that starts after another commits receives a larger timestamp.

3. Which time references does TrueTime use, and why two kinds?

Show the answer

It uses GPS and atomic clocks. They have different failure modes. GPS can suffer antenna or receiver failures, interference, spoofing, and outages. Atomic clocks fail in uncorrelated ways but can drift over long periods.

4. In the microbenchmarks, roughly how much latency came from commit wait versus Paxos?

Show the answer

From the 1-replica experiments, commit wait was about 5ms and Paxos latency was about 9ms.

5. What happened in the availability experiment when the leader zone was killed without warning?

Show the answer

Read completion dropped almost to zero. As leader leases (10 seconds) expired, new leaders were elected. About 10 seconds after the kill, all groups had leaders and throughput recovered. In contrast, a soft kill with leadership handoff caused only around a 3-4% drop.

6. Why does a single prepared transaction hurt reads, and how can this be fixed?

Show the answer

t_safe^TM is bounded by the earliest prepare timestamp, so one prepared transaction stops t_safe from advancing. This blocks reads at later timestamps even if they do not conflict. The fix is to keep a fine-grained mapping from key ranges to prepared-transaction timestamps in the lock table and check reads only against conflicting ranges.

7. Why did the F1 team move from sharded MySQL to Spanner?

Show the answer

Resharding MySQL was extremely costly; the last one took over two years. Spanner removes manual resharding, provides synchronous replication and automatic failover, and supplies the strong transactional semantics F1 needed.

Your answers stay on this page and are cleared when you leave.

Go a little deeper

The paper argues that the overhead of strong semantics shrinks as clock uncertainty bounds tighten. How would Spanner's latency and design trade-offs change if ε stayed large, for example tens of milliseconds? Which of its features would remain worth their cost?

Read next

More papers on Distributed storage.

Related reading lists

All papers explained →

Cite Spanner

Corbett, J. C., Dean, J., Epstein, M., Fikes, A., Frost, C., Furman, J., Ghemawat, S., Gubarev, A., Heiser, C., Hochschild, P., Hsieh, W., Kanthak, S., Kogan, E., Li, H., Lloyd, A., Melnik, S., Mwaura, D., Nagle, D., Quinlan, S., & Rao, R. (2012). Spanner: Google’s Globally-Distributed Database. USENIX OSDI.

@inproceedings{corbett2012spanner,
  title = {{Spanner: Google’s Globally-Distributed Database}},
  author = {James C. Corbett and Jeffrey Dean and Michael Epstein and Andrew Fikes and Christopher Frost and JJ Furman and Sanjay Ghemawat and Andrey Gubarev and Christopher Heiser and Peter Hochschild and Wilson Hsieh and Sebastian Kanthak and Eugene Kogan and Hongyi Li and Alexander Lloyd and Sergey Melnik and David Mwaura and David Nagle and Sean Quinlan and Rajesh Rao and Lindsay Rolig and Yasushi Saito and Michal Szymaniak and Christopher Taylor and Ruth Wang and Dale Woodford},
  year = {2012},
  booktitle = {USENIX OSDI},
  url = {https://www.usenix.org/system/files/conference/osdi12/osdi12-final-16.pdf}
}

Original PDF ↗

Study Spanner in ReadingTrack

Add the paper to your ReadingTrack library with its authors, venue and year, and get this page’s quiz as suggested review cards. You choose which cards to keep; nothing enters your reviews until you accept it.

Last reviewed 26 November 2026 by the ReadingTrack editors. Explanations are our own; quotes are short and attributed, and the paper is linked at its original source.