Google Cloud Tutorial · Storage, Databases and Analytics · Lesson 20 of 27
Databases on Google Cloud
Cloud SQL, AlloyDB, Spanner, Firestore, Bigtable and Memorystore: what each is for and how to choose.
The options
| Database | Type | Choose it for |
|---|---|---|
| Cloud SQL | managed MySQL, PostgreSQL, SQL Server | most relational applications |
| AlloyDB | PostgreSQL-compatible, high performance | demanding PostgreSQL workloads, mixed analytics |
| Spanner | relational, horizontally scalable, strongly consistent | global scale and very high availability |
| Firestore | serverless document database | web and mobile app backends, offline sync |
| Bigtable | wide-column NoSQL | huge throughput by row key: time series, IoT, ad tech |
| Memorystore | managed Redis, Valkey, Memcached | caches and sessions |
| BigQuery | data warehouse | analytics, not transactions |
Cloud SQL essentials
- High availability: a standby in another zone with automatic failover.
- Backups and point-in-time recovery; read replicas, including cross-region for disaster recovery.
- Connect over private IP, with the Cloud SQL Auth Proxy or language connectors, and IAM database authentication to avoid passwords.
- Maintenance windows control when Google patches the instance.
def choose(model, scale, consistency="strong", mobile_sync=False):
if mobile_sync:
return "Firestore"
if model == "relational":
if scale == "global":
return "Spanner"
return "AlloyDB" if scale == "large" else "Cloud SQL"
if model == "wide-column":
return "Bigtable"
if model == "key-value cache":
return "Memorystore"
return "Firestore"
for case in [("relational", "regional"), ("relational", "large"), ("relational", "global"),
("document", "regional", "strong", True), ("wide-column", "huge"), ("key-value cache", "regional")]:
print(case, "->", choose(*case))
Output
('relational', 'regional') -> Cloud SQL
('relational', 'large') -> AlloyDB
('relational', 'global') -> Spanner
('document', 'regional', 'strong', True) -> Firestore
('wide-column', 'huge') -> Bigtable
('key-value cache', 'regional') -> MemorystoreTest yourself
Which database fits a relational workload that must scale horizontally across regions with strong consistency?
Cloud SQLBigtableSpannerMemorystore
Show answer
Answer: Spanner
Spanner combines relational semantics, strong consistency and horizontal, multi-region scale.