Spanner
In one sentence
What it is
Spanner is a distributed relational database. It offers SQL, schemas, secondary indexes and ACID transactions — while distributing data across many machines and, if you choose, across regions.
Historically, systems forced a choice: relational guarantees on one machine, or horizontal scale with weaker consistency. Spanner's significance is that it provides both, using tightly synchronised clocks to order transactions globally.
Why it matters
For systems that genuinely outgrow a single-machine database but cannot give up transactional correctness — payments, ledgers, inventory, global user accounts — there are very few alternatives that do not involve building the consistency logic yourself.
The trade-off is cost. Spanner has a meaningful minimum spend and is substantially more expensive than Cloud SQL for small workloads. Choosing it for a database that would fit comfortably on one machine is a classic over-engineering error, and exams test that judgement.
Key concepts
- Instance — the provisioned capacity, measured in nodes or processing units, plus a chosen configuration.
- Instance configuration — regional for lower cost and latency in one region; multi-region for higher availability and global reads at higher cost.
- Split — the unit of data distribution. Spanner divides tables into ranges and spreads them across servers automatically.
- Primary key design — the most consequential decision you make. Keys determine how data is distributed, and a poor choice creates a hotspot that limits throughput.
- Interleaved tables — physically storing child rows next to their parent rows so related data is fetched together efficiently.
- Strong and stale reads — strongly consistent reads always see the latest data; slightly stale reads can be cheaper and faster when a few seconds of lag is acceptable.
- External consistency — the strongest guarantee Spanner offers: transactions appear in an order consistent with real time, globally.
Choosing between relational options
| Requirement | Answer |
|---|---|
| Standard relational workload that fits on one machine | Cloud SQL — cheaper and simpler. |
| Write throughput beyond a single machine, still needs transactions | Spanner. |
| Single database serving several regions with strong consistency | Spanner in a multi-region configuration. |
| Analytical queries scanning enormous volumes | BigQuery — not an operational database. |
| Migrating an existing MySQL or PostgreSQL application unchanged | Cloud SQL — Spanner requires schema and application changes. |
Common use cases
- Financial ledgers and payment systems needing correctness at scale.
- Global inventory where overselling must be impossible across regions.
- Gaming platforms with worldwide player state and leaderboards.
- Telecommunications and logistics systems with very high transaction volumes.
- Consolidating many sharded databases that have become unmanageable.
Certification relevance
Where this topic appears, and how deeply each exam goes into it. These are our own assessments based on published exam guides.
- Professional Cloud Architect
A frequent correct answer in scenarios combining global scale with transactional requirements — and a frequent wrong answer when the scenario is smaller than it first appears.
- Professional Cloud Database Engineer
Deep coverage: schema design, hotspot avoidance, instance sizing and multi-region configuration.
- Professional Data Engineer
Appears in storage-selection questions distinguishing operational from analytical workloads.
Practice questions
Databases practice questions
8 original questions with full explanations.
Related Certifications
Related Cloud Topics
- Cloud SQLManaged relational databases — MySQL, PostgreSQL and SQL Server — with automated backups, replication and failover.
- BigtableA wide-column NoSQL database built for very high throughput and low-latency lookups over enormous datasets.
- FirestoreA serverless document database with flexible schemas, real-time synchronisation and offline support for client applications.
- BigQueryA serverless analytics warehouse: partitioning, clustering, the cost model, and how to make queries fast and cheap.