How Google Spanner's TrueTime Makes Global Consistency Practical
Google Spanner's TrueTime API achieves external consistency by representing time as an interval and enforcing a commit wait. This blog explains the mechanism, shows a cross-region transaction example, and quantifies the latency trade-offs.
18 Mar 2026, 10:22 UTC

The Problem: Coordinating Time Across Data Centers
Building a globally distributed database that feels like a single-node system means solving a fundamental problem: whose clock do you trust? Network latency, clock drift, and hardware failures make wall-clock time unreliable for ordering transactions across continents. Most distributed databases compromise with eventual consistency or accept the latency of a centralized timestamp oracle. Google Spanner took a different path—it built TrueTime, an API that exposes time as an interval with a bounded uncertainty window, and uses that interval to achieve external consistency without a single global coordinator.
TrueTime Represents Time as an Interval
Instead of returning a single timestamp, TrueTime returns a pair [earliest, latest] representing the earliest and latest possible absolute time. This interval accounts for clock drift between the local machine and the TrueTime masters (atomic clocks and GPS receivers in each data center). The width of the interval, called epsilon (ε), is typically 1–7 milliseconds in production. A transaction's commit timestamp is chosen from within this interval, and the system guarantees that the true absolute time falls somewhere inside it.
This design eliminates the need for a centralized timestamp authority. Each Spanner server can independently assign commit timestamps by consulting its local TrueTime master, reducing coordination overhead for global reads.
The Commit Wait Rule: Turning Uncertainty into Ordering
The key to external consistency is the commit wait rule. After a transaction picks a commit timestamp s (typically latest from its TrueTime interval), it must wait until TT.now().earliest > s before releasing locks and acknowledging the commit. In other words, the transaction pauses until the current time is guaranteed to be past the latest possible value of its commit timestamp.
This wait ensures that any transaction that starts after this commit will see its effects—because its snapshot timestamp will be greater than s. The wait duration equals the uncertainty window ε at the time of commit. If ε is 4 ms, the transaction waits 4 ms. This is the direct latency cost of strong consistency.
Worked Example: A Cross-Region Transfer
Consider a banking application with shards in us-central1 and europe-west1. A user initiates a transfer from account A (US) to account B (EU) in a single distributed transaction.
- The transaction coordinator in
us-central1callsTT.now()and receives[T-2ms, T+2ms](ε = 4 ms). - It picks commit timestamp
s = T+2ms(the interval'slatest). - It coordinates the two-phase commit across shards, writing the debit and credit at timestamp
s. - Before acknowledging, it waits until
TT.now().earliest > T+2ms. With ε = 4 ms, this takes ~4 ms. - Once the wait completes, locks release and the client receives success.
A subsequent read in europe-west1 at timestamp T+3ms will see both the debit and credit because its snapshot timestamp exceeds s. No cross-region coordination was needed for the read—TrueTime's interval guarantee made the ordering deterministic.
Trade-offs: Latency, Hardware, and Configuration Risk
The commit wait latency scales linearly with ε. In a deployment where clock synchronization degrades (e.g., GPS antenna failure, network partition affecting time masters), ε can grow to tens of milliseconds, directly increasing write latency. This is not a theoretical concern—Spanner's SLA accounts for it, and applications sensitive to write latency must design around it.
TrueTime also requires specialized hardware: atomic clocks and GPS receivers in each data center, with redundant time masters. This is why TrueTime is not available in open-source Spanner-compatible databases like CockroachDB or YugabyteDB; they use hybrid logical clocks (HLC) instead, which trade slightly weaker consistency guarantees for commodity hardware deployability.
Misconfiguring the uncertainty window—such as underestimating ε during a leap second or hardware degradation—can violate external consistency. Spanner mitigates this with continuous monitoring of clock offsets and automatic master failover, but operators must understand the monitoring signals.
Verifying the Behavior in Your Workload
If you're evaluating Cloud Spanner for a global application, test the commit wait impact directly:
- Enable
SPANNER_EMULATOR_HOSTfor local development (note: the emulator does not simulate TrueTime wait). - Run a write-heavy benchmark against a multi-region instance (e.g.,
nam6+eur3) and measure p99 write latency. - Compare with the same workload on a single-region instance. The difference approximates the commit wait overhead.
- Check
spanner_sys.txn_statsforcommit_wait_latencypercentiles in production.
For read-heavy workloads, use stale reads (e.g., READ_AT_TIMESTAMP with a 10-second staleness bound) to bypass commit wait entirely—TrueTime still guarantees the snapshot is consistent, just not the absolute latest.
Closing: Choose the Consistency Model Your Latency Budget Allows
TrueTime is a remarkable engineering achievement—it makes external consistency practical at planetary scale by converting clock uncertainty into a measurable, bounded wait. But that wait is real. If your application can tolerate 1–7 ms of additional write latency per transaction (often negligible for OLTP), Spanner's model simplifies reasoning about global state. If you need sub-millisecond writes or run on commodity hardware, hybrid logical clocks in open-source alternatives are the pragmatic choice. The decision isn't about which is \"better\"—it's about whether your latency budget and infrastructure can absorb the commit wait.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.