The coolest thing about Google's Spanner Database is its clock

Arpit Bhayani

Arpit Bhayani

Dec 20, 2023 • 1 min read


The coolest thing about Google’s Spanner Database is its clock synchronization system - TrueTime ⚡

Distributed systems are infamous for losing consistency due to machine clocks going out of sync. To offer strong guarantees, the Spanner relies on having near-accurate time across all the Spanner nodes.

Each node of the Spanner Database runs TrueTime, which requires it to connect to GPS satellites and Atomic Clocks to get the current time. Both GPS and Atomic Clocks are prone to errors and distortions, hence we cannot rely on one for accurate time.

Hence, Spanner nodes combine GPS and Atomic Clock signals using a variant of Network Time Protocol, to produce a highly accurate and consistent time signal. This minimizes the clock skew errors while keeping all nodes in sync with near-accurate time.

⚡ Distributed Systems are truly fascinating 🔥 I keep writing and sharing these engineering nuggets, so if you are keen on learning them, follow along.

youtube.com/c/ArpitBhayani

Arpit Bhayani

Principal Engineer II at Razorpay - building Agent Studio, Ex-staff engg at GCP Memorystore & Dataproc, Creator of DiceDB, ex-Amazon Fast Data, ex-Director of Engg. SRE and Data Engineering at Unacademy. I spark engineering curiosity through my no-fluff engineering videos on YouTube and my courses