Google Cloud Spanner

 

Google Cloud Spanner — Easy Notes

🌐 What is Spanner?

Spanner = Google Cloud’s fully managed relational database designed for very large-scale applications.

The key idea is:

Spanner gives you SQL + relational database features + global scalability + strong consistency.


⭐ Main Features

1. πŸ—„️ Relational Database

Spanner is a relational database, so it supports:

  • SQL
  • Tables
  • Relationships
  • Joins
  • Secondary indexes

So it behaves like a traditional SQL database, but is designed to scale much further.


2. πŸ“ˆ Horizontal Scaling

This is one of the most important points.

Horizontal scaling = add more machines/resources to handle more workload.

For example:

Small workload
     ↓
   Node 1

More workload
     ↓
Node 1 + Node 2 + Node 3 + Node 4

Spanner can distribute data and workload across multiple machines.


3. πŸ”’ Strong Consistency

Strong consistency means that after a successful write, subsequent reads see the correct/latest data.

Example:

You update:
Account Balance = ₹10,000
        ↓
Database
        ↓
Read balance
        ↓
₹10,000 ✅

You don't normally have to worry about one location showing old data while another shows the new data.


4. 🌍 Global Consistency & High Availability

Spanner is designed for applications that need databases operating across multiple regions globally.

It provides:

  • High availability
  • Strong global consistency
  • Distributed database architecture

This makes it suitable for mission-critical applications where downtime or inconsistent data can be very costly.


⚡ Very High Performance

Spanner is designed for workloads requiring very high numbers of reads and writes per second.

The course describes this as:

Tens of thousands of reads and writes per second or more.


πŸ†š Cloud SQL vs Spanner

This is an important distinction:

Cloud SQLSpanner
TypeRelational DBRelational DB
SQL
Managed
ScalingMore traditional/vertical-orientedHorizontal
Global scaleLimited compared with SpannerExcellent
Strong global consistency❌ Not its main feature
High availability✅ Built for large-scale HA
Joins
Secondary indexes
Very high distributed workloadLimited compared with Spanner

🧠 Simple way to remember

Cloud SQL:

"I need a normal managed SQL database."

Spanner:

"I need SQL, but at massive global scale, with strong consistency and high availability."

🎯 Exam shortcut

Spanner = SQL + Horizontal Scaling + Strong Consistency + Global Scale + High Availability.

Comments

Popular posts from this blog

Async/await

First negative in every window of size k

Valid Parentheses