Part 6 of 814 min read · 2 diagramsAI-assisted

Storage & Managed Databases

.mdPDF

Assumes you're comfortable with Part 3's IAM model and Part 5's compute platforms. This chapter is where the compute layer's data actually lives.

Table of Contents#

  1. What This Chapter Covers
  2. Cloud Storage: Classes, Lifecycle, and Autoclass
  3. File Storage: Filestore, NetApp Volumes, and Managed Lustre
  4. Choosing a Managed Database: The Decision Framework
  5. Cloud SQL, AlloyDB, and Spanner: The Relational Family
  6. Firestore and Bigtable: NoSQL for Different Shapes
  7. BigQuery: The Analytics Warehouse
  8. Memorystore and Managed Service for Apache Kafka
  9. Loading Data and Maintaining Multi-Region Redundancy
  10. Backup, Restore, and Customer-Managed Encryption Keys
  11. Database Center: Fleet-Wide Visibility
  12. Estimating Costs and Reviewing Job Status
  13. A Full Worked Example: Meridian's Data Layer End to End
  14. Real-World Scenario: The Connection Storm During a Flash Sale
  15. Second Real-World Scenario: The CMEK Key Rotation That Locked Everyone Out
  16. Part 6 gcloud Cheat Sheet
  17. Pre-Flight Checklist: Is This Data Layer Production-Ready?
  18. Common Mistakes and Interview Traps
  19. Worked Practice Problems
  20. Summary and What's Next

What This Chapter Covers#

🎯 By the end of this chapter, you'll be able to pick the right storage and database product from GCP's genuinely large 2026 catalog, and operate it with the backup, encryption, and cost discipline a production data layer actually needs.

Cloud Storage: Classes, Lifecycle, and Autoclass#

Cloud Storage organizes objects into buckets, each assigned a storage class trading access latency against cost:

ClassMinimum storage durationBest fit
StandardNoneFrequently accessed data, active workloads
Nearline30 daysData accessed roughly monthly
Coldline90 daysData accessed roughly quarterly
Archive365 daysLong-term retention, rarely if ever accessed

Object Lifecycle Management automates transitions between classes (or deletion) based on rules (age, number of newer versions, a specific date), and Autoclass removes the need to write those rules by hand entirely: it observes each object's actual access pattern and moves it between classes automatically, trading a small monitoring overhead cost for guaranteed-optimal placement without manual tuning.

File Storage: Filestore, NetApp Volumes, and Managed Lustre#

Beyond object storage, GCP offers three managed file storage products, each for a genuinely different access pattern:

ProductProtocolBest fit
FilestoreNFSGeneral-purpose shared file storage for applications expecting a POSIX filesystem, including GKE-mounted volumes
NetApp VolumesNFS, SMB, multi-protocolEnterprise workloads already standardized on NetApp's ONTAP data management, or needing SMB alongside NFS
Managed LustreLustre parallel filesystemAI training and HPC workloads needing extreme throughput and sub-millisecond latency at massive scale

Note

Managed Lustre is the newest and most specialized of the three: as of the 2026 Next conference, Google's managed offering scales to 10 TB/s of aggregate throughput for a single instance, positioned specifically for large-scale AI training checkpoint read/write, a workload profile neither Filestore nor NetApp Volumes targets. If an exam scenario mentions training-checkpoint throughput at scale, Managed Lustre is very likely the intended answer.

Choosing a Managed Database: The Decision Framework#

Diagram

Caption: the first fork (relational vs. document vs. wide-column vs. analytical) narrows the field before any performance or scale consideration even enters the decision.

Cloud SQL, AlloyDB, and Spanner: The Relational Family#

Cloud SQLAlloyDBCloud Spanner
Engine compatibilityMySQL, PostgreSQL, SQL ServerPostgreSQL-compatibleIts own (with a PostgreSQL interface option)
Scale ceilingVertical, single-region (with read replicas)Higher than Cloud SQL, PostgreSQL-optimizedHorizontal, global, effectively unbounded
Consistency modelStandard relationalStandard relationalExternally consistent, globally, via TrueTime
Typical fitMost application databasesPostgreSQL workloads outgrowing Cloud SQL's performance ceilingMulti-region applications needing strong consistency at global scale

Choose Cloud SQL by default. Move to AlloyDB when a PostgreSQL workload's read/write latency or throughput genuinely exceeds what Cloud SQL delivers. Move to Spanner when the requirement is specifically global distribution with strong consistency, not just "we're getting big," since Spanner's operational and cost profile only pays off at that specific scale and consistency requirement.

Firestore and Bigtable: NoSQL for Different Shapes#

Firestore is a document database optimized for mobile and web application backends: real-time listeners, offline sync, and a query model built around individual documents and collections. Bigtable is a wide-column store built for massive, high-throughput workloads with a known access pattern, time-series metrics, IoT telemetry, ad-tech event streams, where you're optimizing for sustained write throughput at a scale Firestore isn't designed for.

BigQuery: The Analytics Warehouse#

BigQuery is a serverless data warehouse for ad hoc SQL analytics over datasets from gigabytes to petabytes, billing separately for storage and query compute (on-demand per byte scanned, or a flat-rate slot commitment for predictable, high query volume). Its role in this chapter's decision tree is specifically analytical, not transactional: BigQuery is the wrong choice for an application's live read/write backend, and Cloud SQL/AlloyDB/Spanner/Firestore/Bigtable are the wrong choice for ad hoc analytical queries across a large historical dataset.

Memorystore and Managed Service for Apache Kafka#

Memorystore is GCP's managed in-memory data store, offering Redis, Memcached, and (the newer addition) Valkey-compatible instances, used for caching, session storage, and any workload needing sub-millisecond read latency that a disk-backed database can't provide. Managed Service for Apache Kafka runs real, open-source-compatible Kafka clusters (and Kafka Connect) with Google handling broker sizing, rebalancing, patching, and high availability, using tiered storage (a small amount of fast local disk backed by effectively unlimited remote storage) to keep cost proportional to actual retention needs rather than pre-provisioned local disk.

💡 Managed Service for Apache Kafka's positioning versus Pub/Sub (already familiar from earlier in this series) is worth being precise about: choose Kafka specifically when you need genuine Kafka API compatibility (an existing Kafka-based application, Kafka Connect integrations, or client libraries that assume Kafka semantics), and choose Pub/Sub when you're building new and don't have that compatibility requirement, since Pub/Sub's operational model is simpler and it integrates more directly with the rest of GCP's serverless ecosystem.

Loading Data and Maintaining Multi-Region Redundancy#

Data loading paths scale with volume: gcloud storage cp or the console for small, ad hoc uploads; bq load for structured data going straight into BigQuery; and Storage Transfer Service for large-scale, scheduled, or recurring transfers, including from another cloud provider or an on-premises source, since it handles retry logic and integrity verification that a naive script would need to reimplement.

Multi-region redundancy is a planning consideration the exam calls out explicitly, and it's a genuinely different decision for each product: Cloud Storage's dual-region and multi-region bucket location types replicate objects across geography automatically; Cloud SQL's cross-region read replicas require an explicit topology decision; Spanner's multi-region configurations bake redundancy into the product's core design; and Bigtable/BigQuery each have their own distinct replication mechanisms. There's no single "turn on redundancy" switch across the catalog, each product's redundancy story has to be planned on its own terms.

Backup, Restore, and Customer-Managed Encryption Keys#

Every managed database in this chapter supports automated backups, but the exam's real interest is in restore, not backup configuration: Cloud SQL and AlloyDB support point-in-time recovery within a retention window, Firestore supports scheduled backups and point-in-time recovery, and Spanner and Bigtable each have their own backup mechanisms with product-specific retention limits.

Customer-Managed Encryption Keys (CMEK) let you supply and control the encryption key (via Cloud KMS) used to encrypt a resource's data at rest, instead of relying solely on Google's default encryption. This matters specifically for compliance requirements where the organization itself must control key lifecycle and rotation, and for the ability to render data cryptographically inaccessible by revoking the key, independent of deleting the data itself.

Caution

A CMEK key that's disabled or destroyed makes the data it encrypts permanently unreadable, this isn't a soft lock, it's the mechanism working as designed. See the CMEK rotation scenario below for exactly how this bites a team that treats key rotation casually.

Diagram

Caption: the database never stores your CMEK key directly; it stores data encrypted by a data key that Cloud KMS itself wraps and unwraps on demand, which is exactly why disabling the wrapping key severs access without touching a single byte of the underlying data.

Database Center: Fleet-Wide Visibility#

Database Center is an AI-assisted dashboard giving one aggregated view across an entire database fleet, Cloud SQL, Spanner, Bigtable, AlloyDB, and more, across every project in scope, particularly valuable once an organization's databases are spread across enough projects that no single console view shows the whole picture. It surfaces fleet-wide health issues (a version behind on patches, a missing backup configuration, a compliance-relevant misconfiguration) proactively, and its 2026 conversational interface lets an SRE ask fleet-wide natural-language questions ("which Cloud SQL instances haven't had a successful backup in the last 7 days") instead of manually cross-referencing each project's own console.

Estimating Costs and Reviewing Job Status#

Cost estimation for storage resources combines the calculator (for a rough upfront figure) with the actual billing export from Part 2 (for real, ongoing tracking by label). Reviewing job status applies specifically to asynchronous data operations, a Dataflow pipeline's execution graph, a BigQuery load or query job's progress, both viewable via their respective consoles or gcloud dataflow jobs describe / bq show -j, the operational habit of confirming a data job actually completed successfully rather than assuming a submitted job ran to completion unattended.

A Full Worked Example: Meridian's Data Layer End to End#

# 1. Cloud SQL for the transactional dispatch database, with CMEK
gcloud sql instances create meridian-dispatch-db \
  --database-version=POSTGRES_15 \
  --tier=db-custom-4-16384 \
  --region=us-central1 \
  --disk-encryption-key=projects/meridian-freight-prod-8f2k/locations/us-central1/keyRings/data-layer/cryptoKeys/cloud-sql-key

# 2. Memorystore for session caching in front of it
gcloud redis instances create meridian-session-cache \
  --size=5 --region=us-central1 --tier=standard

# 3. BigQuery dataset for the analytics side, fed by the billing export
bq mk --dataset --location=us-central1 meridian-freight-prod-8f2k:analytics

# 4. A recurring backup verification job, checked against Database Center
gcloud sql backups list --instance=meridian-dispatch-db

Real-World Scenario: The Connection Storm During a Flash Sale#

A promotional flash sale drove Meridian's order-intake service to scale its Cloud Run instances from a handful to several hundred within minutes, and every new instance opened its own pool of direct connections to the backing Cloud SQL instance. Cloud SQL's connection limit was hit within the first ninety seconds, and new orders started failing with FATAL: too many connections well before CPU or memory on the database instance was under any real pressure at all. The immediate cause was Cloud Run's own horizontal autoscaling multiplying connection pools faster than the database's fixed connection ceiling could absorb; the underlying condition was that nobody had put a connection pooler (Cloud SQL's own built-in pooler, or a sidecar like PgBouncer) between the autoscaling compute layer and the database, so every new instance's full connection pool landed directly on Cloud SQL rather than being shared through an intermediary. The fix, deployed before the next promotional event, was Cloud SQL's built-in connection pooling, which multiplexes many client connections over a much smaller number of actual database connections.

Second Real-World Scenario: The CMEK Key Rotation That Locked Everyone Out#

Meridian's security team rotated a CMEK key on a routine 90-day schedule, correctly following their own key-rotation policy, but the automation that rotated the key didn't account for a secondary AlloyDB read replica in a different region that referenced the old key version directly rather than the key's alias. When the old key version was disabled (standard practice after a successful rotation, to reduce the number of live key versions), the read replica's next required key access failed outright, and the replica went unreachable within minutes. The immediate cause was the replica's stale key reference; the underlying condition was that the rotation runbook had been written and tested against the primary instance only, with the secondary replica's independent key dependency never included in the same test. The fix: the rotation runbook was rewritten to explicitly enumerate every resource referencing a given CMEK key (primary and every replica) before disabling any old key version, verified against Database Center's fleet-wide view rather than a manually maintained list.

Part 6 gcloud Cheat Sheet#

TaskCommand
Set a bucket's lifecycle rulegcloud storage buckets update gs://BUCKET --lifecycle-file=RULES.json
Enable Autoclass on a bucketgcloud storage buckets create gs://BUCKET --autoclass
Create a Cloud SQL instancegcloud sql instances create NAME --database-version=VERSION --region=REGION
List Cloud SQL backupsgcloud sql backups list --instance=INSTANCE
Create a Memorystore instancegcloud redis instances create NAME --size=SIZE --region=REGION
Load data into BigQuerybq load DATASET.TABLE SOURCE_FILE SCHEMA
Check a BigQuery job's statusbq show -j JOB_ID
Create a Storage Transfer jobgcloud transfer jobs create SOURCE DESTINATION

Pre-Flight Checklist: Is This Data Layer Production-Ready?#

  • The database choice matches the actual data shape and scale requirement, not just "what the team already knows"
  • A connection pooler sits between any autoscaling compute layer and a relational database with a fixed connection ceiling
  • CMEK rotation runbooks enumerate every resource (including read replicas) referencing a key, not just the primary instance
  • Backup retention and restore have actually been tested, per Part 4's snapshot lesson, applied here to databases
  • Multi-region redundancy has been explicitly designed per product, not assumed to be automatic
  • Database Center (or an equivalent fleet view) is checked on a schedule, not only during an incident

Common Mistakes and Interview Traps#

MistakeWhy it's wrongWhat to say instead
"Spanner is just a bigger Cloud SQL"Spanner's value is global strong consistency, a specific requirement, not simply more scaleMove to Spanner for global consistency needs specifically, not as a generic "we outgrew Cloud SQL" upgrade
"BigQuery can replace our application's operational database"BigQuery is an analytical warehouse, not built for low-latency transactional reads/writesKeep transactional workloads on Cloud SQL/AlloyDB/Spanner/Firestore; use BigQuery for analytics
"Managed Service for Apache Kafka and Pub/Sub are interchangeable"Kafka fits when genuine Kafka API compatibility is required; Pub/Sub is the simpler-operational-model default otherwiseChoose based on compatibility requirements, not just "we need a queue"
"Disabling an old CMEK key version is always safe once rotation completes"Any resource still referencing that specific key version becomes permanently inaccessibleEnumerate every resource referencing a key, including replicas, before disabling an old version
"Autoscaling compute automatically handles database connection limits"More instances mean more connection pools hitting a fixed database ceilingPut a connection pooler between autoscaling compute and any connection-limited database

Worked Practice Problems#

Problem 1: Meridian's AI training team needs to store and rapidly read/write large model checkpoint files during distributed training, with extreme throughput as the primary requirement. Which storage product fits, and why not Filestore or NetApp Volumes?

Answer: Managed Lustre is the right fit. It's specifically built for AI training and HPC workloads needing extreme aggregate throughput and sub-millisecond latency at scale, precisely the checkpoint read/write pattern described. Filestore and NetApp Volumes are both general-purpose or enterprise-oriented NFS/SMB file storage, well suited to typical shared-filesystem application needs, but neither targets the throughput ceiling Managed Lustre is purpose-built to deliver.

Problem 2: During a traffic spike, a Cloud Run service autoscales to 300 instances and a backing Cloud SQL instance immediately starts rejecting new connections with a connection-limit error, well before the database shows any CPU or memory pressure. What's the actual bottleneck, and what's the fix?

Answer: The bottleneck is Cloud SQL's fixed connection limit being exhausted by the sheer number of autoscaled instances each opening their own connection pool, not a compute resource limit on the database itself. The fix is introducing a connection pooler, Cloud SQL's built-in pooling feature or an intermediary like PgBouncer, between the autoscaling compute layer and the database, so many client connections are multiplexed over a much smaller number of actual backend connections.

Problem 3: A security team rotates a CMEK key on schedule and disables the old key version immediately afterward, following their documented process. A secondary database replica in another region goes offline shortly after. What likely went wrong, and how should the runbook change?

Answer: The replica almost certainly referenced the specific old key version directly (rather than a key alias that would have tracked the rotation automatically), and disabling that version made the replica's data permanently inaccessible to it. The runbook should be rewritten to enumerate every resource referencing a given CMEK key, primary instances and every replica alike, and verify each one is either using a key alias or has been explicitly updated to the new key version, before any old version is disabled.

Summary and What's Next#

This chapter covered GCP's storage and database catalog at its current, expanded 2026 scope: object storage lifecycle and Autoclass, the three-way file storage split (Filestore, NetApp Volumes, Managed Lustre), the relational/document/wide-column/analytical decision framework, Memorystore and Managed Service for Apache Kafka as the newer additions to the data layer, and the operational disciplines, tested restores, careful CMEK rotation, connection pooling, fleet-wide visibility via Database Center, that keep it all running correctly under real load.

Part 7 moves to the network these data services and compute platforms all sit on: VPC design, the newer Cloud NGFW policy model replacing plain VPC firewall rules as the primary mental model, load balancing, and hybrid connectivity.