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 SQL | Spanner | |
|---|---|---|
| Type | Relational DB | Relational DB |
| SQL | ✅ | ✅ |
| Managed | ✅ | ✅ |
| Scaling | More traditional/vertical-oriented | Horizontal |
| Global scale | Limited compared with Spanner | Excellent |
| Strong global consistency | ❌ Not its main feature | ✅ |
| High availability | ✅ | ✅ Built for large-scale HA |
| Joins | ✅ | ✅ |
| Secondary indexes | ✅ | ✅ |
| Very high distributed workload | Limited 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
Post a Comment