Chapter Three
Databases
Seven databases spanning relational, document, wide-column, in-memory, analytical, and globally distributed models. Choosing the right one is one of the most consequential and frequently misjudged decisions in architecture.
Quick Selection Guide
Start here. Each entry is one sentence on when to reach for that database. Read the full service page before committing.
- Cloud SQL — relational workloads on PostgreSQL, MySQL, or SQL Server. The right starting point for most teams.
- AlloyDB — PostgreSQL when you have measured a real performance limit on Cloud SQL.
- Spanner — SQL with ACID transactions at global scale and horizontal write scaling. A different architecture, not a faster Cloud SQL.
- BigQuery — analytical queries over large datasets. Not a transactional database.
- Firestore — document-structured data in mobile or web apps that need real-time sync and offline support.
- Bigtable — very high-throughput time series, IoT telemetry, and operational analytics with known key access patterns.
- Memorystore — caching, session storage, and any workload that needs sub-millisecond latency.
The two most common database selection mistakes: choosing based on familiarity rather than workload fit, and over-anticipating scale requirements that never arrive.
Cloud SQL — Postgres, MySQL, SQL Server; regional. AlloyDB — Postgres-only, higher throughput. Spanner — horizontal and global with strong (external) consistency.
Firestore — document DB with strong per-document reads and managed scaling; server-side or mobile/web with offline sync. Bigtable — wide-column, very high throughput, low latency for known key patterns; strongly consistent within a cluster.
BigQuery — serverless warehouse for large scans and aggregations. Not transactional, not for low-latency lookups.
Memorystore — Redis/Valkey, sub-millisecond. A cache or session store, not a primary persistent database; Cluster mode shards horizontally.
Pick by data model and scale first. Consistency is often a setting, not a fixed trait — Spanner is strongly consistent, Bigtable is strong within a cluster — so choose it deliberately rather than reading it off a position.
Services in This Chapter
Service 09
Cloud SQL
Managed PostgreSQL, MySQL, and SQL Server. The right starting point for relational workloads.
Service 10
BigQuery
Serverless analytical data warehouse. SQL at petabyte scale. No clusters to provision.
Service 11
Firestore
Serverless document database. Real-time listeners, mobile offline sync, scales from zero.
Service 12
Spanner
Globally distributed SQL with ACID transactions. Horizontal write scaling across regions.
Service 13
Bigtable
Wide-column NoSQL for very high throughput. Time series, IoT, operational analytics.
Service 14
Memorystore
Managed Redis and Memcached. Sub-millisecond latency for caching and session storage.
Service 15
AlloyDB
PostgreSQL-compatible with 4x higher transactional throughput and 100x faster analytics.