Most distributed databases treat physical wall clocks as untrustworthy liars and fall back to logical counters or weaker isolation levels. Spanner flips that tradeoff: instead of pretending a server’s clock reads a single exact instant, its TrueTime API returns an explicit uncertainty interval [earliest, latest] backed by GPS receivers and atomic clocks, then forces write commits to wait out that uncertainty before exposing new data.

Built over more than five years at Google and proven on Google’s F1 advertising backend (which migrated tens of terabytes off a manually sharded MySQL setup whose final resharding took over two years), Spanner showed that global distribution does not require abandoning SQL, schemas, or strict serializability. That insight reshaped every distributed SQL engine that followed, including systems that later approximated TrueTime without atomic clocks using hybrid logical clocks.

  • Explicit uncertainty bounds: TT.now() returns [earliest, latest] with half-width epsilon ranging from 1ms to 7ms in production (averaging 4ms across 30-second poll intervals and a 200 microseconds/second worst-case drift rate).
  • Commit wait buys external consistency: Assigning commit timestamp s >= TT.now().latest and waiting until TT.after(s) (expected wait at least 2 * epsilon, measured around 5ms in single-replica benchmarks) ensures real-time ordering across non-overlapping transactions.
  • Lock-free reads scale with replicas: Read-only transactions and snapshot reads acquire zero locks; across 1 to 5 replicas, snapshot-read latency holds steady at 1.2 to 1.3ms while throughput scales nearly linearly from 13.5 to 50.0 Kops/sec.
  • 2PC layered over Paxos: Running two-phase commit across Paxos-replicated groups rather than bare machines removes single-coordinator blocking and scales to 50 participants at 42.7ms mean latency (150.5ms at 200 participants).
Spanner’s architecture: placement, spanserver stack, and TrueTime
1. Universe & directories
Zones deploy across datacenters; directories (or fragments) are the unit of placement and locality.
INTERLEAVE IN & movedir
Parent-child tables co-locate contiguous keys; movedir shifts a 50MB directory between Paxos groups in seconds without stalling reads or writes.
2. Spanserver stack
Each spanserver hosts 100 to 1,000 multi-version tablets backed by B-tree files and WAL on Colossus.
Pipelined Paxos + Lock Table + 2PC
Single Paxos state machine per tablet with 10s timed leader leases; leaders run wound-wait 2PL and coordinate cross-group 2PC.
3. TrueTime clock plane
Per-datacenter GPS and Armageddon atomic masters sync machine daemons via Marzullo’s algorithm.
TT.now() & tsafe
Bounds commit ordering globally via commit wait while letting any replica serve lock-free reads up to tsafe.

Architecture from Corbett et al. (2012), Sections 2 through 4.

TrueTime: turning clock drift into an explicit interval

Standard time APIs give applications a scalar number and hide how wrong it might be. TrueTime exposes only three calls (Table 1): TT.now(), which returns a TTinterval [earliest, latest] guaranteed to contain the true absolute time of invocation t_abs(e_now); TT.after(t), true only when t has definitely passed (t < earliest); and TT.before(t), true only when t has definitely not arrived (latest < t). Define the instantaneous error bound epsilon as half the interval width.

To keep epsilon both small and trustworthy, TrueTime pairs two independent time references per datacenter because they fail in uncorrelated ways. Most time masters use dedicated GPS antennas (physically separated to resist antenna damage, local interference, and spoofing), yet GPS still suffers from receiver bugs, leap-second errors, and satellite outages. The remaining Armageddon masters carry rubidium-style atomic clocks, which cost roughly the same as GPS masters and drift independently.

Every machine runs a timeslave daemon polling nearby and remote GPS masters plus Armageddon masters every 30 seconds, running a variant of Marzullo’s algorithm to reject outlier “liars” and evicting machines whose local crystals exceed a conservative worst-case drift rate of 200 microseconds per second. Between polls, uncertainty grows linearly (200 us/s * 30s = 6ms), plus roughly 1ms network communication delay, giving a production sawtooth epsilon of 1 to 7ms and an average bound of 4ms. Over Google’s fleet measurements in Section 5.3, bad CPUs were 6 times more likely than local clocks drifting beyond 200 us/sec.

Reifying that interval lets Spanner sidestep traps that crippled earlier distributed storage layers.

Three distributed-database traps Spanner avoids
Unbounded wall clocks

Naive NTP timestamps let a later transaction receive an earlier timestamp under skew, violating linearizability.

Bare 2PC coordinators

If a non-replicated coordinator crashes mid-prepare, participants hold locks indefinitely; Spanner runs 2PC over Paxos groups.

Leaderless Megastore

Letting any replica initiate Paxos writes caused non-conflicting transactions to collide, collapsing throughput to several writes/sec.

Comparisons from Corbett et al. (2012), Sections 2.1, 2.3, and 6.

External consistency via commit wait, leader leases, and safe time

Spanner’s headline guarantee is external consistency (equivalent to strict serializability, or linearizability over multi-key transactions): if transaction T1 commits before transaction T2 starts in real time (t_abs(e_commit_1) < t_abs(e_start_2)), then T1’s commit timestamp must be strictly smaller (s1 < s2).

The proof in Section 4.1.2 takes four lines and depends on two rules enforced by the 2PC coordinator leader:

  1. Start rule: Once the commit request for T_i arrives at the coordinator leader (e_server_i), the leader picks a commit timestamp s_i at least as large as TT.now().latest (and at least as large as every participant’s prepare timestamp and any timestamp previously assigned in that group).
  2. Commit Wait rule: The coordinator leader does not release locks or expose any committed data from T_i until TT.after(s_i) returns true.

Because Commit Wait delays external visibility until s_i is guaranteed to lie in the past (s1 < t_abs(e_commit_1)), and causality guarantees T2’s commit request reaches its coordinator after T2 starts (t_abs(e_start_2) <= t_abs(e_server_2) <= s2), transitivity seals s1 < s2. That guarantee costs an expected wait of at least 2 * epsilon (roughly 5ms in Table 3’s single-replica test, overlapped with Paxos replication rounds whenever WAN latency exceeds 2 * epsilon).

Two subtle mechanisms keep timestamps monotonic across leaders and keep reads fast:

  • Disjoint Paxos leader leases: Spanner runs long-lived Paxos leaders using 10-second timed leases (Section 4.1.1 and Appendix A). Instead of writing every lease extension synchronously to the Paxos log, a leader computes a conservative lease start and end from TT.now() while replicas obey a single-vote rule (refusing any new lease vote until TT.after(t_end) holds) and an abdicating leader waits until TT.after(s_max) passes. Overlapping quorums guarantee consecutive leaders’ lease intervals never overlap, keeping timestamps monotonic even across leader transitions.
  • Safe time (tsafe) and idle advancement: Every replica tracks tsafe = min(tPaxos_safe, tTM_safe). tPaxos_safe is the highest applied Paxos write timestamp, while tTM_safe is min(s_prepare - 1) across prepared-but-uncommitted 2PC transactions on that group (or infinity if none exist). Any replica with t <= tsafe can answer historical reads locally without contacting a leader or taking locks. To prevent idle Paxos groups from stalling snapshots, leaders periodically advance MinNextTS(n) every 8 seconds (bounded within their lease) so followers can advance tPaxos_safe even with zero write traffic, and Section 4.2.4 tracks tTM_safe per key range inside the lock table so one prepared transaction does not block unrelated reads.

Trace Spanner’s transaction paths and failure modes

Spanner separates operations into four distinct execution paths (Table 2) plus non-blocking schema updates so reads pay almost none of the coordination tax required by multi-site writes. Switch through the five tabs below to trace how each operation executes, where the cost sits, and how the system behaves under datacenter failure.

Five execution and failure paths inside Spanner

Select a path (or use Left and Right arrow keys) to compare concurrency control, TrueTime mechanics, and measured latencies.

Multi-group read-write transaction over 2PC and Paxos

Pessimistic 2PL

Clients buffer writes locally, acquire wound-wait read locks at group leaders, then drive 2PC directly to avoid double WAN hops.

Why naive fix breaks
Optimistic concurrency control degrades badly on minute-long transactions under conflict; non-replicated 2PC stalls when a coordinator crashes.
Spanner's mechanism
Participants take write locks and log prepare timestamps via Paxos; coordinator chooses s >= max(prepare, TT.now().latest), logs commit, waits TT.after(s), then applies.
Microbenchmark cost
Commit wait adds ~5ms (14.4ms write latency across 1, 3, or 5 replicas vs. 9.4ms with commit wait disabled); 2PC mean scales from 17.0ms (1 group) to 42.7ms (50) and 150.5ms (200).
F1 production latency
Across 24 hours on Google's ad backend (Table 6): 31.2M single-site commits averaged 72.3ms (std dev 112.8ms); 32.1M multi-site commits averaged 103.0ms.

Source: Corbett et al. (2012), Sections 4 and 5.

If you prefer the short version without clicking through the tabs, here is how Spanner handles all five paths:

  • Read-write transactions: pessimistic wound-wait 2PL plus 2PC over Paxos groups, paying 2 * epsilon commit wait (~5ms in microbenchmarks; 72.3ms single-site and 103.0ms multi-site mean in F1).
  • Read-only transactions: lock-free execution at LastTS() (single group) or TT.now().latest (multi-group) on any replica with tsafe >= s_read, holding 1.3 to 1.4ms latency.
  • Snapshot reads: lock-free past reads scaling linearly with replica count (up to 50.0 Kops/sec at 5 replicas and 1.3ms latency) for backups, audits, and F1 cache hydration.
  • Atomic schema changes: non-blocking transitions pinned to a future TrueTime timestamp t so only transactions after t wait for the schema cutover.
  • Zone failures: zero drop on follower-zone failure, 3 to 4% blip on graceful leader handoff, and up to a 10-second pause (matching leader lease length) on abrupt leader-zone loss.

Caveats, cost of TrueTime, and what changed later

Three caveats frame what the 2012 paper achieved and what it left open.

First, external consistency does not erase wide-area physics or contention tails. Commit wait adds 2 * epsilon, and synchronous Paxos replication still waits for a WAN quorum round-trip. On F1’s 5-replica US deployment (two west coast, three east coast), multi-site commits averaged 103.0ms (std dev 52.2ms), and single-site commits still showed a 112.8ms standard deviation from lock contention (Table 6). Even Spanner’s storage path carried expediency debt in 2012: every Paxos write was logged twice (once in the tablet WAL and once in the Paxos log, Section 2.1).

Second, TrueTime’s guarantees rest on operational assumptions and monitoring. If a local clock crystal drifted faster than 200 microseconds/second without getting evicted, or if time masters suffered correlated failures, TT.now() bounds could be violated. Routine maintenance on two datacenter time masters on April 13 caused a ~1-hour spike in epsilon above 6 to 10ms (Figure 6), directly lengthening commit wait. Similarly, sudden leader-zone crashes freeze affected Paxos groups for the full 10-second lease window.

Third, several database essentials were still missing or immature in 2012. Spanner did not yet support automatic secondary indexes (F1 maintained consistent global indexes manually in application transactions across 100-to-500-fragment directories, Table 5), lacked in-Paxos membership changes (relying on movedir), and had node-local B-tree layouts poorly tuned for complex SQL analytics (Section 7). Since 2012, Google’s Zanzibar built global permission checks directly on Spanner’s external consistency and zookie snapshot tokens, Cloud Spanner tightened TrueTime bounds into sub-millisecond regimes, and open-source distributed SQL databases adopted hybrid logical clocks to approximate Spanner’s read-only semantics on commodity cloud VMs without GPS antennas.

For engineers designing geo-distributed services today, Spanner’s core lesson is architectural honesty about time. Rather than pretending NTP clocks are synchronized or giving up on global consistency altogether, measure your clock-error bound explicitly, decide which reads truly need real-time external order versus cheap bounded-staleness snapshots, and remember that keeping a leader lease long-lived and colocated with callers matters as much to tail latency as the clock hardware itself.