← Lessons

quiz vs the machine

Gold1500

Databases

Google Spanner and TrueTime

How bounded clock uncertainty lets a global database offer external consistency.

6 min read · core · beat Gold to climb

A Globally Distributed SQL Database

Google Spanner spreads data across data centers worldwide yet still offers strong transactions. The hard part is ordering transactions consistently when clocks on different machines disagree. Spanner solves this with TrueTime.

What TrueTime Provides

Ordinary clocks return a single timestamp that may be wrong. TrueTime instead returns an interval with an earliest and latest possible time, backed by GPS receivers and atomic clocks. The width of this interval is the uncertainty.

Commit Wait

When a transaction commits, Spanner picks a timestamp and then deliberately waits until the uncertainty interval has fully passed before releasing the result. This commit wait guarantees that any later transaction sees a strictly greater timestamp.

Why This Matters

The payoff is external consistency, the strongest practical guarantee. If transaction A finishes before transaction B starts in real time, then A is ordered before B everywhere. Smaller clock uncertainty means shorter waits and higher throughput, which is why the hardware investment pays off.

Key idea

TrueTime exposes bounded clock uncertainty, and by waiting out that interval at commit Spanner guarantees external consistency for transactions spread across the globe.

Check yourself

Answer to earn rating on the learn ladder.

1. What does TrueTime return instead of a single timestamp?

2. What is the purpose of commit wait?

3. Why does smaller clock uncertainty improve throughput?