SysDesign study
Offline — showing the cached copy.
Home / Software System Design / 15. Spanner and F1 — globally consistent SQL

15. Spanner and F1 — globally consistent SQL

One-liner. Use synchronized clocks to avoid coordination on every read.

Context. AdWords needed a globally distributed, strongly consistent relational store — sharded MySQL could not provide cross-shard transactions.

Public architecture (Spanner, OSDI 2012).

  • Data is split into tablets; each tablet is a Paxos group replicated across zones/Regions.
  • TrueTime exposes clock uncertainty [earliest, latest]; transactions wait out the uncertainty (commit-wait) to get external consistency.
  • Reads at a timestamp are served from any sufficiently caught-up replica; writes go through the Paxos leader.
  • F1 (AdWords) added a SQL layer, schema changes without downtime, and hierarchical indexes.

Design lesson. Strong global consistency is a latency trade, not a free property: you pay commit-wait and cross-Region round trips. Most systems should isolate the part that truly needs it (money, inventory) and keep the rest eventually consistent.

SPANNER WRITE Client Paxos leader Replica A Replica B commit-wait(TrueTime) ack
Spanner write

Trade-off. Cross-Region writes cost a WAN round trip; multi-Region reads can be local but stale-bounded.

Trap. Choosing global strong consistency because it sounds safer, then discovering 150 ms writes. Do this. Split the domain: ledger in a consistent store, feeds/analytics eventually consistent.

Check

What does Spanner's commit-wait buy?