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-widthepsilonranging 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().latestand waiting untilTT.after(s)(expected wait at least2 * 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).
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.
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:
- Start rule: Once the commit request for
T_iarrives at the coordinator leader (e_server_i), the leader picks a commit timestamps_iat least as large asTT.now().latest(and at least as large as every participant’s prepare timestamp and any timestamp previously assigned in that group). - Commit Wait rule: The coordinator leader does not release locks or expose any committed data from
T_iuntilTT.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 untilTT.after(t_end)holds) and an abdicating leader waits untilTT.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 trackstsafe = min(tPaxos_safe, tTM_safe).tPaxos_safeis the highest applied Paxos write timestamp, whiletTM_safeismin(s_prepare - 1)across prepared-but-uncommitted 2PC transactions on that group (or infinity if none exist). Any replica witht <= tsafecan answer historical reads locally without contacting a leader or taking locks. To prevent idle Paxos groups from stalling snapshots, leaders periodically advanceMinNextTS(n)every 8 seconds (bounded within their lease) so followers can advancetPaxos_safeeven with zero write traffic, and Section 4.2.4 trackstTM_safeper 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.
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 2PLClients 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.
Predeclared read-only transaction with snapshot isolation
Lock-freeClients predeclare a read-only transaction and its key scope so Spanner picks a safe read timestamp and executes without acquiring locks.
- Why naive fix breaks
- Treating a read-only transaction as a write-free RW transaction still takes two-phase locks and blocks incoming writes.
- Spanner's mechanism
- Single-group reads pick s_read = LastTS() at the leader when no prepares are active; multi-group reads pick s_read = TT.now().latest and run on any replica with tsafe >= s_read.
- Microbenchmark cost
- In Table 3, read-only transaction latency stays 1.3 to 1.4ms across 1, 3, and 5 replicas while throughput rises from 10.9 to 25.3 Kops/sec.
- Retry property
- Once s_read is chosen, commit is inevitable (barring GC); failed reads resume on another replica using the same timestamp and read cursor.
Non-blocking historical read at an exact or bounded timestamp
Past readsAudits, backups, and MapReduce jobs read consistent global state in the past from any sufficiently caught-up replica.
- Why naive fix breaks
- Taking distributed snapshots without shared time bounds requires stopping writes or running Chandy-Lamport barriers across thousands of machines.
- Spanner's mechanism
- Clients pass an explicit timestamp or staleness bound; any replica with t <= tsafe answers directly from multi-versioned tablets without touching a leader.
- Microbenchmark cost
- Snapshot reads deliver 1.2 to 1.3ms latency and scale almost linearly with replicas: 13.5 (1), 38.5 (3), and 50.0 Kops/sec (5 replicas).
- F1 production use
- F1 initializes in-memory caches from consistent timestamp snapshots and streams incremental history changes, averaging 8.7ms across 21.5B daily reads.
Non-blocking atomic schema changes at global scale
Future timestampInstead of running 2PC across millions of Paxos groups or halting traffic like Bigtable, Spanner schedules schema transitions at a future TrueTime timestamp.
- Why naive fix breaks
- Bigtable blocks all operations during atomic schema updates; standard 2PC across millions of groups is operationally infeasible.
- Spanner's mechanism
- Register an explicit future timestamp t in prepare; concurrent transactions assigned timestamps before t proceed unimpeded, while timestamps after t synchronize on t.
- Why TrueTime is vital
- Without globally bounded clocks, assigning a coordinated future instant t across thousands of unrelated servers would have no consistent meaning.
- Operational effect
- Schema updates roll out cleanly across globally replicated tables while keeping ongoing production read and write traffic flowing.
Datacenter failure under 10-second Paxos leader leases
AvailabilityKilling a non-leader zone has zero throughput impact, while an ungraceful leader-zone kill pauses affected groups until leases expire.
- Why naive fix breaks
- Immediate leader takeover without lease expiration would allow two leaders to assign overlapping timestamps concurrently.
- Spanner's behavior
- In Figure 5 (5 zones, 1,250 groups, 50K reads/s), killing non-leader Z2 causes zero drop; soft-killing leader Z1 with handoff drops throughput only 3 to 4%.
- Hard leader-zone kill
- Killing Z1 without warning drops completion rate near 0 until 10s leases expire evenly over the next 10s, then queued requests spike recovery to ~100K reads/s.
- Planned improvement
- Shorter leases shrink outages at higher renewal traffic cost; the authors note work on letting slaves release leases explicitly upon detected leader failure.
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 * epsiloncommit 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) orTT.now().latest(multi-group) on any replica withtsafe >= 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
tso only transactions aftertwait 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.


