Global e-commerce platform requiring ACID transactions, strong consistency, and 99.999% availability across multiple continents.
→Cloud Spanner with a multi-region configuration (e.g., nam-eur-asia).
Why: Spanner is the only GCP managed service providing globally distributed, strongly consistent ACID transactions at scale with a 99.999% SLA.
Reference↗
Migrating a large, high-performance Oracle OLTP database with complex stored procedures and analytical query needs.
→AlloyDB for PostgreSQL.
Why: AlloyDB offers superior PostgreSQL performance, Oracle compatibility features, and a columnar engine for accelerating analytical queries (HTAP) without impacting transactional workloads.
Reference↗
High-throughput (millions of OPS) ingestion of time-series data (e.g., IoT, logs) requiring low-latency reads and automatic data expiration.
→Cloud Bigtable with a row key design of `(entity_id)#(reverse_timestamp)` and a garbage collection policy.
Why: Bigtable is designed for massive-scale, low-latency key/value workloads. A reverse timestamp in the row key co-locates recent data for efficient scans. Garbage collection handles TTL.
Reference↗
Mobile or web application requiring a flexible schema, real-time data synchronization to clients, and offline support.
→Firestore in Native Mode.
Why: Firestore is purpose-built for this serverless app backend pattern, providing real-time listeners and offline persistence via its client SDKs out-of-the-box.
Reference↗
Large-scale (10M+ vectors) similarity search for AI/ML applications (e.g., RAG, recommendations) needing sub-100ms latency.
→AlloyDB for PostgreSQL with pgvector extension and a ScaNN index.
Why: AlloyDB integrates Google's high-performance ScaNN algorithm for approximate nearest neighbor (ANN) search, outperforming standard vector search implementations at scale.
Designing a Cloud Spanner schema for a write-heavy workload to prevent hotspots on a single server.
→Design primary keys that do not use monotonically increasing values (e.g., sequential IDs, timestamps) as the first key part. Use UUIDs, hashed values, or bit-reversed sequences instead.
Why: Spanner distributes data lexicographically by primary key. Sequential keys direct all writes to a single split, creating a hotspot. Randomly distributed keys spread writes across all splits.
Reference↗
A Spanner schema has a strong parent-child relationship (e.g., Customers and Orders) and queries frequently fetch a parent with all its children.
→Use interleaved tables, defining the child table with `INTERLEAVE IN PARENT`.
Why: Interleaving physically co-locates child rows with their parent row in storage. This makes parent-child joins extremely efficient, as it becomes a highly optimized range scan on a single split.
Tracking real-time locations for a massive fleet of vehicles (50k+ writes/sec) with queries to find vehicles within a geographic area.
→Cloud Bigtable with a row key prefixed by a GeoHash of the vehicle's location.
Why: Bigtable handles the extreme write throughput. GeoHash encoding converts 2D coordinates into a 1D string where prefixes represent geographic proximity, enabling efficient geospatial range scans.
Storing and analyzing petabyte-scale data (e.g., genomic data, logs) with complex analytical SQL queries.
→Store raw data in Cloud Storage and query it directly from BigQuery using external tables, or load into native BigQuery storage.
Why: BigQuery is a serverless data warehouse built for petabyte-scale analytics. Its separation of storage and compute provides unparalleled query performance and cost-effectiveness for OLAP workloads.
A high-availability in-memory cache for complex data structures (hashes, sets) with pub/sub capabilities for cache invalidation.
→Memorystore for Redis Standard Tier with read replicas.
Why: Standard Tier provides a 99.9% SLA with automatic failover. Redis supports complex data types and pub/sub, unlike Memcached. Read replicas can scale read throughput.
Designing a multi-tenant SaaS application on Spanner requiring strong data isolation and performance guarantees per tenant.
→Use tenant_id as the first component of the primary key for all tables. For stronger isolation, use a database-per-tenant model within a single Spanner instance.
Why: A tenant_id prefix naturally co-locates all of a single tenant's data, optimizing queries and allowing Spanner to split data by tenant. Database-per-tenant provides the strongest logical isolation.