SaveMyCert
Log in
5 of 5 free questions left today·for unlimited practice
Planning and implementing a cloud solution

Choosing Storage and Databases: Cloud SQL, BigQuery, Spanner, and More

13 min readACE · Planning and implementing a cloud solutionUpdated

Choose a Google Cloud data product by matching three properties of the workload — data model, scale, and consistency needs — to the service built for exactly that combination: Cloud SQL for regional relational apps, Spanner for globally consistent relational scale, AlloyDB for demanding PostgreSQL, Firestore for mobile and web document data, Bigtable for massive-throughput wide-column workloads, BigQuery for analytics, Memorystore for caching, and Pub/Sub, Dataflow, and Managed Service for Apache Kafka for data in motion. Object, file, and block storage follow the same logic: Cloud Storage for objects with four classes priced by access frequency, and Filestore, NetApp Volumes, and Managed Lustre for shared file systems. Exam sub-section 2.2 tests whether you can make these selections from a scenario, deploy the winner with gcloud, load data into it efficiently, and keep it redundant across regions. This lesson walks each decision, the deployment commands, and the multi-region options service by service.

What you’ll learn
  • Select the right database from Cloud SQL, Spanner, Firestore, Bigtable, AlloyDB, and BigQuery using data model, scale, and consistency requirements
  • Choose the correct Cloud Storage class — Standard, Nearline, Coldline, or Archive — from access frequency and minimum storage duration
  • Deploy data and storage products with gcloud, including Cloud SQL instances, Spanner instances, Firestore databases, and Cloud Storage buckets
  • Match streaming and messaging workloads to Pub/Sub, Dataflow, Managed Service for Apache Kafka, and Memorystore
  • Load data with gcloud storage uploads, BigQuery loads from Cloud Storage, and Storage Transfer Service, choosing the right tool by data size and cadence
  • Design multi-region redundancy across Cloud Storage, Cloud SQL, Spanner, Firestore, Bigtable, and BigQuery

How to choose a database on Google Cloud

Ask three questions in order and the answer usually falls out. First, what shape is the data — relational rows with joins and transactions, JSON-like documents, wide-column key-value at huge scale, or analytical tables you scan in aggregate? Second, what scale and where — one region or global, gigabytes or petabytes? Third, what consistency and latency — strict transactions, or eventual freshness with sub-millisecond reads? Relational plus regional scale means Cloud SQL (managed MySQL, PostgreSQL, and SQL Server) or, for demanding PostgreSQL performance, AlloyDB. Relational plus horizontal, global scale with strong consistency means Spanner — it is the only option that combines all three. Flexible documents with mobile and web sync means Firestore. Massive-throughput, low-latency wide-column data — time series, IoT, personalization — means Bigtable. Scanning terabytes for analytics with SQL means BigQuery, which is a serverless data warehouse, not an operational database.

RequirementCloud SQLSpannerFirestoreBigtableBigQuery
Data modelRelational (MySQL, PostgreSQL, SQL Server)Relational with SQLDocument (collections)Wide-column NoSQLColumnar analytical tables
Scale modelVertical, regionalHorizontal, regional to globalAutomatic, large scaleHorizontal, massive throughputServerless, petabytes
ConsistencyStrong (single primary)Strong, globallyStrongEventually consistent replication across clustersAnalytical (not transactional OLTP)
Sweet spotExisting apps, CMS, ERP, standard web backendsGlobal financial, inventory, gaming stateMobile and web apps, user profiles, real-time syncIoT, time series, ad tech, personalizationData warehousing, BI, log analytics
Wrong whenNeeds global writes or beyond single-instance scaleSmall app that Cloud SQL handles cheaperComplex joins and heavy analyticsSmall data or SQL and multi-row transactions neededServing single-row operational lookups

Scenario: a global ticketing platform needs strongly consistent seat inventory across three continents — Spanner, because Cloud SQL cannot scale writes globally and Firestore's model does not fit relational inventory. Its analytics team then loads sales history for dashboarding — BigQuery. Its mobile app stores user preferences with offline sync — Firestore. The exam nearly always includes one requirement (global strong consistency, document sync, petabyte scans) that eliminates all but one service.

Deploying relational databases: Cloud SQL, AlloyDB, and Spanner

Cloud SQL is the default relational answer, and you deploy it in one command: gcloud sql instances create app-db --database-version=POSTGRES_16 --region=us-central1 --tier=db-custom-2-8192. For availability, enable regional HA at creation with --availability-type=REGIONAL, which maintains a synchronous standby in a second zone and fails over automatically — note this is zonal fault tolerance within one region, not multi-region. Read scale comes from read replicas, which can live in the same region or a different one; cross-region replicas are also Cloud SQL's disaster-recovery story, because you can promote one to a standalone primary.

AlloyDB is the step up for PostgreSQL: a Google-built, PostgreSQL-compatible engine that separates compute from storage and adds a columnar engine for fast analytical queries over operational data. Choose it over Cloud SQL when the question stresses demanding PostgreSQL performance, hybrid transactional-and-analytical queries, or migrating a heavyweight PostgreSQL estate that has outgrown Cloud SQL — while staying wire-compatible with PostgreSQL tools.

Spanner is deployed as an instance with a configuration that fixes its geography: gcloud spanner instances create orders --config=regional-us-central1 --processing-units=100 --description=Orders. The config is the redundancy decision — regional-* configs replicate across zones in one region, while multi-region configs replicate across regions for global strong consistency and higher availability. Capacity is sized in processing units or nodes and scales horizontally without downtime. The trade-off to remember: Spanner costs more at small scale, so if a scenario fits comfortably in Cloud SQL, Spanner is the over-engineered wrong answer.

One gotcha across all three: these are regional-or-wider managed services — you never SSH into them, and machine-level tuning questions about them are distractors.

Deploying NoSQL and in-memory: Firestore, Bigtable, and Memorystore

Firestore is created once per database as a project-level resource with a location that cannot be changed later: gcloud firestore databases create --location=nam5 creates a multi-region database (nam5 spans multiple regions for the highest availability), while a regional location like us-central1 costs less. Firestore gives you strongly consistent document reads and queries, real-time listeners, offline sync for mobile and web clients, and automatic scaling with no capacity planning — which is why mobile app backend is its exam cue. Choose Native mode for new applications; Datastore mode exists for server-side workloads built on the older Datastore API.

Bigtable is provisioned as an instance containing one or more clusters: gcloud bigtable instances create metrics --display-name=Metrics --cluster-config=id=metrics-c1,zone=us-central1-b,nodes=3. It is a wide-column store designed for very high read and write throughput at consistently low latency over huge datasets — time series, IoT telemetry, ad serving, personalization. Scale by adding nodes; add clusters in other zones or regions for replication (covered under redundancy below). Its limits are the selection signal: no SQL joins in the operational path, single-row transactions only, and it is not cost-effective for small datasets — if the scenario is small or needs multi-row transactions, Bigtable is wrong.

Memorystore is the managed in-memory layer — Redis-compatible and Valkey offerings plus Memcached — used as a cache or session store in front of a database: gcloud redis instances create session-cache --size=5 --region=us-central1 --tier=STANDARD_HA creates a Redis instance with a replica and automatic failover (BASIC tier has no replication, so a failure loses the cache). Exam cue: reduce read latency for repeated lookups or store user sessions outside the app means Memorystore, not a bigger database.

Analytics and data in motion: BigQuery, Dataflow, Pub/Sub, and Managed Kafka

BigQuery is the serverless data warehouse: you create datasets and tables, load or stream data in, and query with standard SQL while Google handles all capacity — bq mk --location=US sales_ds then bq load --source_format=CSV sales_ds.orders gs://sales-bucket/orders.csv ./schema.json. There is no instance to size, which is precisely why it is the analytics answer and never the operational-database answer: it is optimized for scanning columns across billions of rows, not for single-row lookups behind an application.

The streaming trio divides by job. Pub/Sub is the global messaging backbone — publishers send to topics, subscribers pull or receive pushes, delivery is at-least-once with automatic scaling — the answer for decoupling services and ingesting event streams: gcloud pubsub topics create clickstream and gcloud pubsub subscriptions create clickstream-sub --topic=clickstream. Dataflow is the managed processing engine (Apache Beam) that transforms data in motion or at rest — the answer whenever a question says transform, enrich, deduplicate, or window a stream, and Google provides prebuilt templates for common paths such as Pub/Sub to BigQuery. Managed Service for Apache Kafka runs real Kafka clusters as a managed service — the answer only when the scenario explicitly requires Kafka compatibility, usually migrating an existing Kafka estate without rewriting producers and consumers; for greenfield messaging, Pub/Sub is the simpler, serverless default.

Scenario: clickstream events publish to a Pub/Sub topic; a Dataflow streaming job windows and enriches them; results land in BigQuery for dashboards. That three-step pipeline — Pub/Sub ingests, Dataflow processes, BigQuery analyzes — is the canonical pattern the exam expects you to assemble from a description.

Cloud Storage classes and bucket deployment

Cloud Storage prices the same durable object storage four ways, trading lower at-rest cost for retrieval fees and minimum storage durations. All classes share the same 11-nines durability design, the same APIs, and millisecond first-byte access — colder classes are not slower to read, they just charge for retrieval and early deletion. Pick by how often you touch the data:

ClassAccess patternMinimum storage durationCost profileTypical use
StandardFrequent (hot data)NoneHighest at-rest, no retrieval feeServing website assets, active data lakes, staging
NearlineAbout once a month or less30 daysLower at-rest, retrieval fee appliesRecent backups, content accessed occasionally
ColdlineAbout once a quarter or less90 daysLower still, higher retrieval feeQuarterly-accessed archives, DR copies
ArchiveLess than once a year365 daysLowest at-rest, highest retrieval feeCompliance retention, long-term archives

The minimum duration is the classic trap: deleting or rewriting an Archive object after two months still bills the full 365 days. Create a bucket with a default class and location: gcloud storage buckets create gs://acme-backups --location=us --default-storage-class=NEARLINE --uniform-bucket-level-access. Location is chosen at creation and is permanent: a region for lowest latency next to your compute, a dual-region for two named regions with active-active access, or a multi-region like us for the broadest geo-redundancy. Autoclass can manage class transitions automatically, and Object Lifecycle Management rules (a Section 3 topic) downgrade or delete objects on a schedule you define.

File storage: Filestore, NetApp Volumes, and Managed Lustre

Object storage is not a file system, so when a workload needs a shared POSIX file system mounted by many clients at once, you reach for the file family. Filestore is the default: managed NFS file shares that Compute Engine VMs and GKE Pods mount concurrently — the answer for lift-and-shift apps expecting an NFS mount, shared home directories, and content-management workloads. Create one with gcloud filestore instances create shared-fs --zone=us-central1-a --tier=BASIC_SSD --file-share=name=share1,capacity=2560GB --network=name=default, then mount it over NFS from any client in the VPC. Higher tiers add capacity, performance, and availability options.

Google Cloud NetApp Volumes is the enterprise option: fully managed NetApp ONTAP file storage supporting both NFS and SMB, with enterprise data-management features such as snapshots and replication. Its exam cue is explicit — SMB shares for Windows-based workloads or an organization standardized on NetApp tooling migrating to Google Cloud. Managed Lustre serves the opposite extreme: a managed parallel file system for high-performance computing and AI training, where thousands of clients need massive aggregate throughput to shared scratch data. If the scenario says HPC cluster or feeding a large training job from a shared file system, Managed Lustre is the answer; for everything ordinary, it is over-engineered.

Selection in one line: general NFS means Filestore, SMB or NetApp enterprise features mean NetApp Volumes, HPC-scale parallel throughput means Managed Lustre, and if no client actually needs a mounted file system, step back to Cloud Storage.

Loading data: uploads, BigQuery loads, and Storage Transfer Service

Choose a loading tool by size, source, and cadence. For ad hoc uploads from a workstation or VM, use the gcloud storage commands (successor to the legacy gsutil): gcloud storage cp ./export.csv gs://acme-ingest/ copies a file, and gcloud storage rsync ./data gs://acme-ingest/data --recursive synchronizes a directory, transferring only differences — the right answer for scripted, repeatable pushes of moderate size. Large single files are uploaded as parallel composite chunks automatically, but the tool is still bounded by your machine and network, which is the limitation that motivates the next option.

For large-scale or recurring movement, use Storage Transfer Service: a managed service that transfers data into Cloud Storage from other cloud object stores, HTTP endpoints, other buckets, and — via agents — on-premises file systems, with scheduling, filtering, checksumming, and retries handled for you. Exam cues: terabytes from another cloud provider's object storage, nightly sync from a data center, or move objects between buckets on a schedule all mean Storage Transfer Service, not a scripted copy. For truly massive offline datasets where the network is the bottleneck, Google offers a physical appliance option, but the scheduled-network-transfer scenarios on the exam belong to Storage Transfer Service.

Loading into databases follows a two-step pattern: stage in Cloud Storage, then load. BigQuery loads directly from a bucket — bq load --source_format=NEWLINE_DELIMITED_JSON app_ds.events gs://acme-ingest/events/*.json — with load jobs free of query cost. Cloud SQL imports SQL dumps or CSV from a bucket with gcloud sql import sql app-db gs://acme-ingest/dump.sql --database=app; grant the instance's service account read access to the bucket first, the most common failure the exam probes. Firestore and Spanner similarly import from Cloud Storage exports, and Dataflow templates cover streaming and transform-heavy loads.

Maintaining multi-region redundancy across data solutions

Multi-region redundancy is configured differently in every service, and the exam tests that you know which knob each one exposes. In Cloud Storage, it is the bucket location: multi-region and dual-region buckets store data redundantly across regions automatically, and dual-region buckets can add turbo replication for a faster replication objective — nothing to operate, just choose the location at creation. In Spanner, it is the instance configuration: pick a multi-region config at creation and Spanner synchronously replicates with global strong consistency and automatic failover. In Firestore, it is the database location: multi-region locations such as nam5 or eur3 replicate across regions with strong consistency and the highest availability tier.

Services without a single switch use replicas. Cloud SQL achieves cross-region redundancy with cross-region read replicas that you promote during a regional outage — an explicit, operator-driven failover, distinct from the automatic zonal failover of regional HA; remember that pairing: HA is zonal, replicas are regional DR. Bigtable replicates by adding clusters in other regions to an instance; replication is asynchronous and eventually consistent, and app profiles route traffic between clusters for failover or multi-cluster serving. BigQuery datasets placed in a multi-region location such as US or EU are stored redundantly within that geography, and cross-region dataset replication can copy datasets between regions for disaster recovery. Memorystore offers replicas and, in its cluster offerings, cross-zone distribution — but a cache should be rebuildable by design.

Scenario: a health-tech company must survive a full regional outage. It stores documents in a dual-region bucket with turbo replication, runs Spanner in a multi-region config for patient-facing transactions, keeps a cross-region Cloud SQL replica for a legacy reporting app, and places BigQuery datasets in the US multi-region. Four services, four different mechanisms — knowing which is automatic (Storage, Spanner, Firestore, BigQuery within a multi-region) and which is operator-driven (Cloud SQL promotion, Bigtable app-profile failover) is exactly what the question will probe.

Tip. Expect selection questions that describe a workload and force one database from Cloud SQL, Spanner, Firestore, Bigtable, AlloyDB, and BigQuery — one requirement such as global strong consistency, offline sync, or petabyte SQL scans eliminates the rest. Cloud Storage questions hinge on class minimum durations and retrieval trade-offs, on choosing regional versus dual-region versus multi-region locations, and on when Storage Transfer Service beats a gcloud copy. Redundancy questions test which services make multi-region a creation-time choice versus which need replicas you fail over yourself, with the Cloud SQL zonal-HA-versus-cross-region-replica distinction a recurring favorite.

Key takeaways
  • Select databases by data model, scale, and consistency: Cloud SQL for regional relational, Spanner for globally consistent relational scale, Firestore for documents with sync, Bigtable for massive-throughput wide-column data, BigQuery for analytics.
  • AlloyDB is the PostgreSQL-compatible step up from Cloud SQL for demanding transactional-plus-analytical workloads; Memorystore is the managed cache and session store, not a system of record.
  • Pub/Sub ingests and decouples, Dataflow transforms streams and batches, Managed Service for Apache Kafka exists for Kafka-compatibility requirements — Pub/Sub to Dataflow to BigQuery is the canonical streaming pipeline.
  • Cloud Storage classes trade at-rest price against retrieval fees and minimum durations: Standard (none), Nearline (30 days), Coldline (90 days), Archive (365 days) — all with the same durability and millisecond access.
  • Bucket location is permanent and is the redundancy decision: regional for latency, dual-region for two active regions (optionally with turbo replication), multi-region for broadest geo-redundancy.
  • File workloads map to Filestore for NFS, NetApp Volumes for SMB and enterprise NetApp features, Managed Lustre for HPC-scale parallel throughput.
  • Load small and scripted data with gcloud storage cp and rsync; use Storage Transfer Service for large, recurring, or cross-cloud transfers; stage in Cloud Storage then load into BigQuery or import into Cloud SQL.
  • Multi-region redundancy is automatic where it is a location or config choice (Cloud Storage, Spanner, Firestore, BigQuery) and operator-driven where it uses replicas (Cloud SQL cross-region replica promotion, Bigtable multi-cluster replication).

Frequently asked questions

When is Spanner the right answer instead of Cloud SQL?

Choose Spanner when the scenario demands horizontal write scaling beyond a single instance, strong consistency across regions, or availability higher than a regional database can offer — global inventory, financial ledgers, worldwide gaming state. If the workload fits in one region at a scale a single primary handles, Cloud SQL is cheaper and simpler, and Spanner becomes the over-engineered wrong answer. The eliminating phrase to watch for is globally consistent transactions.

What is the difference between Nearline, Coldline, and Archive storage?

They are progressively colder Cloud Storage classes for progressively rarer access: Nearline targets roughly monthly access with a 30-day minimum storage duration, Coldline roughly quarterly with a 90-day minimum, and Archive less than yearly with a 365-day minimum. At-rest price drops with each step while retrieval fees rise. All classes keep the same durability and millisecond first-byte latency — the trade is purely financial, and deleting an object before its minimum duration still bills the full period.

When should I use Bigtable instead of Firestore?

Use Bigtable when the workload is massive-scale, high-throughput, low-latency key-value or time-series data — IoT telemetry, ad serving, personalization — where you design row keys for scan patterns and accept single-row transactions with eventually consistent cross-cluster replication. Use Firestore for application document data: user profiles, app state, anything needing flexible queries, strong consistency, real-time listeners, and mobile or web offline sync. Small datasets are a Bigtable anti-pattern; it earns its cost at large scale.

How does Storage Transfer Service differ from gcloud storage cp?

gcloud storage cp (and rsync) is a client-side tool: your machine reads the data and writes it to the bucket, which is perfect for ad hoc and scripted uploads but bounded by that machine's network. Storage Transfer Service is a managed service that moves data into Cloud Storage from other cloud object stores, HTTP sources, other buckets, or on-premises agents, with built-in scheduling, filtering, integrity checking, and retries — the answer for large, recurring, or cross-cloud transfers.

Does Cloud SQL high availability protect against a regional outage?

No. Cloud SQL regional high availability keeps a synchronous standby in a different zone of the same region and fails over automatically, so it survives zonal failures only. To survive a regional outage you create a cross-region read replica and promote it to a standalone primary during disaster recovery — an explicit operator action. The exam frequently tests this exact distinction: HA is zonal and automatic, cross-region replicas are regional DR and manual.

When would I choose Managed Service for Apache Kafka over Pub/Sub?

Choose Managed Service for Apache Kafka when the requirement is Kafka itself: migrating an existing Kafka deployment, keeping producer and consumer code that speaks the Kafka protocol, or preserving Kafka ecosystem tooling without rewriting. For new event-driven architectures with no Kafka dependency, Pub/Sub is the default — serverless, globally scaled, and with nothing to size or manage. The exam cue is the word Kafka in the requirements; absent that, prefer Pub/Sub.

Test yourself on this topic
Practice questions with full explanations.
Practice now

Sign up free to mark lessons complete, bookmark topics and track your exam readiness.