TrueTime: Designing Global External Consistency in Google Spanner
TrueTime gives Google Spanner global external consistency by returning a bounded time interval and enforcing a commit‑wait rule, eliminating a central timestamp oracle and keeping latency predictable.
07 Dec 2025, 04:59 UTC

Problem Statement
When a database spans continents, the order in which transactions appear to clients must be preserved across all replicas. Traditional approaches rely on a centralized timestamp oracle, which becomes a bottleneck and a single point of failure. The challenge is to provide a globally consistent order without central coordination while keeping latency low.
Architectural Requirements
- External consistency: if transaction A finishes before B starts, B must observe a timestamp greater than A’s.
- Horizontal scalability: each data center should operate independently.
- Fault tolerance: no single component can bring the system down.
- Predictable latency: the consistency mechanism should add minimal overhead.
The Smallest Suitable Design: TrueTime + Paxos
The core of the solution is Google Spanner’s TrueTime API, which returns a bounded time interval – [earliest, latest] – instead of a single timestamp. The interval length, called epsilon (ε), is kept small (typically 7–10 ms) by synchronizing atomic clocks and GPS receivers at every data center.
Coupled with Paxos groups that manage synchronous replication within each shard, this design eliminates the need for a centralized timestamp service. Each shard can assign commit timestamps locally, then rely on the global ordering enforced by TrueTime.
Trust & Data Boundaries
- Clock Trust Boundary: Each data center’s TrueTime implementation is trusted to provide an accurate uncertainty bound. If the bound is violated, the node shuts down to prevent consistency breaches.
- Paxos Boundary: Replication is confined to a Paxos group; cross‑shard ordering is achieved via TrueTime, not inter‑group communication.
Commit Wait Rule (Operational Check)
- Transaction requests commit.
- The coordinator assigns a commit timestamp
s = TrueTime.now().latest. - The coordinator blocks until
TrueTime.now().earliest > s.- When this condition holds, the current physical time is guaranteed to be after
s.
- When this condition holds, the current physical time is guaranteed to be after
- Transaction is committed and made visible.
Because earliest is never earlier than the true time, any transaction that starts after the commit will receive a timestamp strictly greater than s, ensuring external consistency.
Concrete Example
Assume a data center’s TrueTime uncertainty is 8 ms. A transaction arrives at 12:00:00.000. The coordinator reads TrueTime.now() and obtains [12:00:00.000, 12:00:00.008]. It assigns s = 12:00:00.008 and waits until the clock’s earliest time is > 12:00:00.008. If the clock ticks forward every millisecond, the commit will be released after roughly 8 ms of waiting, adding negligible latency to the overall request.
Failure Modes and Mitigations
| Condition | Impact | Mitigation |
|---|---|---|
| Clock drift exceeds expected epsilon | Increased commit latency or consistency risk | Node shuts down; remaining nodes continue operation. |
| GPS or atomic clock failure | Uncertainty increases, potentially exceeding safe bounds | System falls back to high‑precision local oscillators until hardware is restored. |
| Paxos group quorum loss | Replication stalls | Automatic re‑electing of leaders and replication from surviving replicas. |
When the Design Changes
- If application latency requirements become stricter than the current epsilon allows, a tighter clock synchronization mechanism would be required, which may increase operational cost.
- Deployments without access to atomic clocks or GPS (e.g., public cloud VMs) cannot achieve the same epsilon, making TrueTime impractical; alternative consensus‑based timestamping would be needed.
- If the system scales to a new geographic region where hardware support is limited, the design must incorporate additional redundancy or fallback strategies.
Limitations
TrueTime is a proprietary infrastructure component; replicating its behavior in generic cloud environments is not feasible without specialized hardware. The design also assumes that the underlying Paxos implementation can guarantee synchronous replication within the shard, which may not hold in highly partitioned networks.
Practical Verification
- Inspect the
TrueTime.now()interval on a live node and confirm thatlatest - earliestmatches the documented epsilon. - Run a small benchmark that measures the average commit wait time under varying clock uncertainty to verify that latency stays within acceptable bounds.
- Simulate a clock skew event and observe that the node transitions to a safe shutdown state.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.