Google Cloud · Comparison
Cloud SQL vs AlloyDB vs Spanner vs Firestore
Which operational database should I use on Google Cloud?
Decision summary
Default to Cloud SQL for relational applications that fit on one primary instance with read replicas.
Move to AlloyDB when PostgreSQL performance or mixed analytics outgrow Cloud SQL.
Choose Spanner only when you need relational data that scales horizontally with strong consistency across regions or extreme availability; it's powerful but costs more and changes how you design schemas.
Choose Firestore for document data in web and mobile apps, especially with real-time sync and serverless billing. For huge key-based throughput, look at Bigtable instead.
Best fit for each option
Cloud SQL
Typical relational apps on MySQL, PostgreSQL or SQL Server.
AlloyDB
Busy PostgreSQL workloads and analytics on operational data.
Spanner
Global, strongly consistent relational data at very large scale.
Firestore
Document data for mobile and web apps, real-time listeners, serverless billing.
Side by side
| Cloud SQL | AlloyDB | Spanner | Firestore | |
|---|---|---|---|---|
| Best for | Standard relational apps | High-performance PostgreSQL | Global relational scale | Documents for apps |
| Scaling | Vertical, read replicas | Vertical primary, read pools | Horizontal, online | Automatic, serverless |
| Availability | Zonal HA standby; cross-region replicas | HA by default in the region | Regional or multi-region (up to 99.999%) | Regional or multi-region |
| Cost | Instance size and storage | Instances and storage used | Compute capacity and storage | Per operation and stored data |
| Operational complexity | Low; you size instances | Low; you size instances and pools | Low; schema and key design matter | Lowest; data modelling matters |
When to avoid each option
Cloud SQL
- Write volume beyond one machine or global writes.
AlloyDB
- Small databases where Cloud SQL is cheaper.
- MySQL or SQL Server.
Spanner
- Small, regional apps that don't need its scale or price.
Firestore
- Joins, complex transactions and relational integrity.
Example scenarios
| Situation | Choose | Why |
|---|---|---|
| A SaaS product with 200 GB of PostgreSQL data in one region | Cloud SQL | Fits one primary with HA and replicas. |
| An inventory system taking writes in Europe, America and Asia | Spanner | Global consistent writes are its purpose. |
| A mobile app that syncs user data offline | Firestore | Client SDKs with offline persistence and real-time updates. |
| Reporting queries slowing down a busy PostgreSQL database | AlloyDB | Its columnar engine speeds analytics on operational data. |
Exam cues
- Global, strongly consistent relational: Spanner. Regional relational: Cloud SQL.
- Serverless documents, mobile sync: Firestore. High-performance PostgreSQL: AlloyDB.
Service pages
- Cloud SQL · Managed MySQL, PostgreSQL and SQL Server with automated backups, high availability, read replicas and maintenance windows.
- AlloyDB for PostgreSQL · A PostgreSQL-compatible database built for demanding transactional workloads, with a columnar engine for fast analytics.
- Spanner · A relational database that scales horizontally across regions while staying strongly consistent, with up to 99.999% availability.
- Firestore · A serverless document database for web, mobile and server apps, with real-time listeners and offline sync.
Related
Courses and lessons
- The Region Went Down · Google Cloud in Production · Members
Services, comparisons and patterns
- Cloud SQL · Service
- AlloyDB for PostgreSQL · Service
- Spanner · Service
- Firestore · Service
- Bigtable · Service
Sources
Independent study material, not affiliated with or endorsed by Amazon Web Services.