3: Storing the data

    Selecting storage systems. Considerations include

    Key points

    Storage selection is the most heavily weighted topic in Section 3 of the exam, and it is the topic where distractors map most cleanly to wrong services.

    A correct answer is almost always justified by one or more of these constraints:

    • the shape of read and write access
    • the latency budget
    • the size of a single row or document
    • the durability and consistency model
    • the cost shape
    • the operational ceiling of the service

    The Professional Data Engineer exam never asks "which service is best" in the abstract; it always provides a scenario in which one option satisfies every constraint and the rest fail at least one. The objective of this section is to internalize the constraints first, then map them to the managed offerings.

    A second pattern that appears across the exam is the difference between a service that can technically handle a workload and the service that is designed for it. Spanner can store wide-column data, Bigtable can serve as a session cache, BigQuery can hold point lookups; all three are wrong answers in scenarios where Bigtable, Memorystore, and Firestore respectively are designed for the workload.

    The right answer is the service whose cost shape, operational model, and SLA align with the workload, not just the service that can hold the bytes.

    Analyzing data access patterns

    Access pattern analysis decomposes a workload into seven dimensions before any service is named. The first three describe the shape of the request: read or write skew, predicate selectivity, and aggregation depth.

    A workload with high read skew and low write skew suits an analytical engine; a workload with high write skew and uniform key distribution suits a wide-column store. Predicate selectivity decides whether partitioning and clustering will reduce scan size; if every query reads every row, partitioning saves nothing.

    Aggregation depth determines whether the engine should compute on disk pages (column store) or return rows to the client (row store).

    The next two dimensions describe the value shape: row size and access locality. A row that exceeds a few megabytes is unsuited to Spanner (which holds a documented 10 MiB per-cell upper bound on mutation size for some operations and a strong preference for sub-megabyte rows), unsuited to Bigtable (which targets cells under 10 MiB and rows under 100 MiB but performs best at sub-megabyte scale), and best handled in Cloud Storage with an external index.

    Access locality refers to whether requests cluster around a recent time range, a small key prefix, or are randomly distributed; locality determines whether caching, partitioning, or sharding will dominate.

    The final two dimensions describe the operational envelope: consistency requirement and durability requirement. Consistency ranges from strong external consistency (Spanner, AlloyDB primary), through strong serializable consistency within a region (Cloud SQL primary, BigQuery query semantics), through eventual consistency within a single key (Bigtable replicated cluster), to best-effort caching (Memorystore).

    Durability ranges from 11 nines on Cloud Storage multi-region (99.999999999% annual object durability) down to zero durability for Memorystore Basic tier, with intermediate points at Memorystore Standard tier (which adds a replica) and Memorystore for Redis Cluster (which adds sharding and replication).

    💡 Exam Trap: A scenario that lists "millisecond latency, millions of writes per second, time-series keys" points to Bigtable, not BigQuery streaming inserts. BigQuery accepts streaming writes through the Storage Write API but it is not a low-latency point-read store. The presence of "per-row lookup" in the same scenario eliminates BigQuery entirely.

    💡 Exam Trap: A scenario that says "session state for a web app, sub-millisecond reads, optional persistence" points to Memorystore. If the scenario adds "globally consistent across regions, transactional", that is Spanner, not Memorystore, because Memorystore is regional and not transactional in the SQL sense.

    Choosing managed services

    The service catalog for the exam covers nine offerings. Each entry below names the canonical workload, the cost shape, and the constraint that disqualifies it.

    BigQuery is the serverless analytical warehouse. It stores data in columnar Capacitor files, executes queries on the Dremel engine across a pool of slots, and supports SQL with arrays and structs. Cost shape is per byte scanned (on-demand) or per slot-hour (Editions: Standard, Enterprise, Enterprise Plus). The disqualifier is point-lookup latency: a single-row select on a multi-terabyte table without a clustering match still scans at least one block group, taking seconds.

    BigLake extends BigQuery to data stored in Cloud Storage, Amazon S3, or Azure Blob Storage. A BigLake table is a metadata object in BigQuery that points to files (Parquet, ORC, Avro, CSV, JSON, or Apache Iceberg) and applies row-level, column-level, and policy-tag security regardless of whether the reader is a BigQuery query or an external engine that uses the BigLake connector. The disqualifier is that BigLake is not a storage system itself; it inherits the durability and consistency of the underlying object store.

    AlloyDB is a PostgreSQL-compatible managed database engineered for both transactional and analytical workloads. It uses a primary cluster with up to 20 read pool instances and a columnar engine that converts hot rows into a column-organized in-memory cache, accelerating analytical queries against transactional data. Cost shape is per vCPU-hour plus storage. The disqualifier is geographic scope: AlloyDB primary is regional with cross-region replication for read pools and disaster recovery, not globally synchronous like Spanner.

    Bigtable is a wide-column NoSQL store with single-digit-millisecond reads and writes at petabyte scale. It uses a row-key indexed model and supports HBase API access. Cost shape is per node-hour plus storage (SSD or HDD). Disqualifiers are multi-row transactions (Bigtable supports single-row atomicity only) and complex query patterns (only key, key range, and key prefix scans are efficient).

    Spanner is the globally distributed relational database with external consistency through TrueTime, horizontal scaling through splits, and SQL plus a GoogleSQL extension. Cost shape is per processing unit or per node-hour plus storage, with multi-region instances costing more per node. The disqualifier is the cost floor: Spanner is the most expensive managed database per gigabyte stored, so a workload that does not require global consistency or extreme scale should go to AlloyDB or Cloud SQL.

    Cloud SQL offers managed MySQL, PostgreSQL, and SQL Server, with regional high availability through a standby instance and read replicas in other regions. Cost shape is per vCPU-hour plus storage plus optional HA premium. Disqualifiers are scale ceiling (Cloud SQL Enterprise Plus tier raises the limits, but a single instance still tops out below Spanner) and the lack of native multi-region writes.

    Cloud Storage is the object store with eleven nines of annual durability for objects in multi-region and dual-region locations, four storage classes (Standard, Nearline, Coldline, Archive), and three location types (region, dual-region, multi-region). Cost shape is per gigabyte-month, with cheaper classes paying less for storage and more for access. Disqualifier is structured query: Cloud Storage holds bytes, not rows.

    Firestore is a serverless document database.

    • The Firestore in Native mode supports real-time listeners, mobile and web SDKs, and strong consistency within a document.
    • The Firestore in Datastore mode supports the legacy Datastore API with eventual consistency for queries and strong consistency within an entity group. Cost shape is per operation (read, write, delete) plus per gigabyte stored. Disqualifier is analytical query: Firestore is not designed for full-table scans.

    Memorystore offers managed Redis (Basic, Standard tiers, plus Redis Cluster) and Memcached. It is in-memory, regional, and intended as a cache or session store. Cost shape is per gigabyte-hour of memory. Disqualifier is durability:

    • Memorystore Basic has no replica and survives only a clean restart.
    • Standard has one replica.
    • Redis Cluster shards data across nodes but does not promise the durability of a disk-backed store.

    Decision Tree: Selecting a Managed Storage Service

    The decision tree resolves more than ninety percent of selection scenarios.

    The remaining cases involve mixed workloads (e.g., a transactional store that also serves a small analytical workload) and are addressed by the Decision Anchor below. Decision Anchor:

    • Choose BigQuery when the workload is analytical, the latency budget allows seconds per query, and the data volume exceeds the practical limits of a single Cloud SQL or AlloyDB instance.
    • Choose Spanner when the workload requires both relational semantics and global writes with external consistency.
    • Choose Bigtable when the workload requires single-digit-millisecond writes at high throughput with key-based access.
    • Choose AlloyDB when the workload is PostgreSQL-compatible OLTP with embedded analytical reporting.
    • Choose Cloud SQL when the workload is a smaller-scale OLTP application without analytical reporting needs.
    -- Example: BigQuery query that disqualifies a wrong service choice
    -- This query joins a fact and dimension and aggregates over a partitioned date column.
    -- A Cloud SQL or Spanner equivalent would require a much larger instance to match
    -- BigQuery's parallelism on the scan, illustrating why the analytical workload belongs in BigQuery.
    SELECT
     d.region,
     DATE_TRUNC(f.event_date, MONTH) AS month,
     SUM(f.revenue_usd) AS revenue
    FROM `acme_analytics.sales_facts_v1` AS f
    JOIN `acme_analytics.dim_region_v1` AS d
     ON f.region_id = d.region_id
    WHERE f.event_date BETWEEN '2024-01-01' AND '2024-12-31'
    GROUP BY d.region, month
    ORDER BY revenue DESC;
    
    # Example: Provisioning a Bigtable instance for a time-series workload.
    # The SSD storage type is required for single-digit-millisecond latency.
    # The cluster is set in us-central1 with three nodes; autoscaling will adjust within bounds.
    gcloud bigtable instances create acme-events-ts \
     --display-name="ACME Events Time Series" \
     --cluster=acme-events-ts-c1 \
     --cluster-zone=us-central1-a \
     --cluster-num-nodes=3 \
     --cluster-storage-type=SSD
    
    # Add autoscaling so the cluster expands under load and shrinks when idle.
    gcloud bigtable clusters update acme-events-ts-c1 \
     --instance=acme-events-ts \
     --autoscaling-min-nodes=3 \
     --autoscaling-max-nodes=10 \
     --autoscaling-cpu-target=60
    

    Planning for storage costs and performance

    Cost shape determines the lever the engineer pulls when a workload exceeds budget. The exam tests cost-shape recognition through scenarios that pair a service with a billing pattern; if the pattern does not match, the service is wrong.

    BigQuery on-demand billing charges per byte scanned, with a one-megabyte minimum per table per query. Costs drop when queries hit a partition or cluster filter, when materialized views satisfy the query, or when BI Engine serves results from memory. BigQuery Editions billing charges per slot-hour, with autoscaling that adds and removes slots as queue depth changes; this shape is cheaper for predictable workloads above a certain volume, and is the only option for streaming workloads above the on-demand quota. The break-even point depends on the workload mix.

    Comparison

    Spanner is billed per processing unit (one hundred PUs equal one node) plus storage per gigabyte-month. Multi-region instances cost more per PU than regional ones, and PU consumption is driven by CPU utilization and storage size. Bigtable is billed per node-hour plus storage per gigabyte-month, with SSD storage substantially more expensive per gigabyte than HDD storage but offering the latency the service is designed for.

    Cloud Storage cost is dominated by storage class and access frequency. The Standard class has the highest storage cost and zero retrieval cost. Nearline, Coldline, and Archive successively reduce storage cost while charging retrieval per gigabyte and imposing minimum storage durations. Object Lifecycle Management can move objects between classes automatically. Memorystore is billed per gigabyte-hour of provisioned memory and is the most expensive per gigabyte for stored bytes among all the services in this section.

    📊 Limit: Cloud Storage minimum storage durations apply for Nearline (30 days), Coldline (90 days), and Archive (365 days). Deleting an object before the minimum duration is reached results in a prorated early-deletion charge as if the object had remained for the full minimum period. This is the most asked Cloud Storage cost trap on the exam.

    📊 Limit: BigQuery streaming inserts via the legacy insertAll API have a per-table streaming buffer size limit and per-project quota. The Storage Write API replaces insertAll for new pipelines and offers exactly-once semantics with the default stream; it has substantially higher quotas and is the right answer for any "high-throughput streaming into BigQuery" scenario.

    Performance levers per service are summarized in the table below.

    ServicePrimary Performance LeverSecondary Lever
    BigQueryPartitioning on dominant filter columnClustering on dominant join or filter sub-key
    SpannerSchema design to avoid hot keysInterleaved tables for parent-child access locality
    BigtableRow-key design to spread writes across tabletsColumn family separation to control read amplification
    AlloyDBRead pool sizing and columnar engine cacheIndex tuning on PostgreSQL primary
    Cloud SQLVertical scaling of primaryRead replicas for read-heavy workloads
    Cloud StorageObject size and request shapeStorage class and location selection
    FirestoreIndex design and document sizeBundle and offline cache patterns
    MemorystoreEviction policy and memory sizeTier selection (Basic, Standard, Cluster)

    ⚠️ Anti-Pattern: Provisioning Spanner with a single monotonically increasing primary key (timestamp, sequence number, UUIDv1). The hot tail concentrates writes on a single split, capping throughput at the single-split limit regardless of how many nodes the instance has. The exam tests this with the keyword "hot spot" or "uneven throughput across nodes". The fix is to hash the prefix or invert the timestamp.

    Lifecycle management of data

    Lifecycle management addresses three questions:

    • when does data move to cheaper storage,
    • when is it deleted,
    • when does it become immutable.

    Cloud Storage Object Lifecycle Management applies rules per bucket; each rule has a condition (age, storage class, version count, custom time, days since custom time) and an action (set storage class, delete, abort incomplete upload). Rules evaluate once per object per day and apply at midnight UTC.

    How it works

    BigQuery offers partition expiration (set per table or inherited from dataset default) and table expiration. Time travel retains modified and deleted data for a configurable window between two and seven days, default seven; fail-safe storage retains an additional seven days beyond time travel without configuration. Once both windows elapse, storage is reclaimed and physical bytes are removed. The exam tests this distinction by mixing "I deleted a row five days ago, can I recover it" (yes, via time travel) with "I deleted a row twenty days ago" (no, fail-safe also expired).

    For long-term retention with immutability, Bucket Lock applies a retention policy to a bucket that prevents object deletion or overwrite for the configured duration. Object Holds (event-based or temporary) prevent deletion of a specific object regardless of bucket retention. These are the two answers for regulated retention scenarios.

    # Cloud Storage lifecycle policy moving objects from Standard to Nearline at 30 days,
    # Coldline at 90 days, and deleting at 365 days. Applied to the bucket via gsutil or gcloud storage.
    lifecycle:
     rule:
     - action:
     type: SetStorageClass
     storageClass: NEARLINE
     condition:
     age: 30
     matchesStorageClass:
     - STANDARD
     - action:
     type: SetStorageClass
     storageClass: COLDLINE
     condition:
     age: 90
     matchesStorageClass:
     - NEARLINE
     - action:
     type: Delete
     condition:
     age: 365
    

    🎯 Scenario: An online retailer streams order events into BigQuery for analytics and a copy into Cloud Storage for raw archive. Analytics dashboards query the last 90 days; auditors may request raw data up to seven years old, with the requirement that it cannot be deleted before seven years. The right design partitions the BigQuery table by order_date with a 90-day partition expiration on a derived "hot" table, retains a full warm table with a longer expiration, and stores Cloud Storage raw events in a bucket with a seven-year Bucket Lock retention policy and lifecycle transitions from Standard to Coldline at 90 days and to Archive at 365 days. This pattern combines BigQuery partition expiration for cost control with Bucket Lock for regulatory immutability.

    💡 Exam Trap: A "GDPR right to be forgotten" scenario in Cloud Storage cannot be satisfied by a bucket under Bucket Lock with the deletion request inside the retention window. The lock prevents deletion even by the bucket owner. The correct design uses customer-supplied encryption keys (CSEK) or customer-managed encryption keys (CMEK) per data subject, then destroys the key, which renders the objects unrecoverable without deleting them. This is sometimes called crypto-shredding.

    Section synthesis on selection trade-offs

    Storage selection is rarely about picking one perfect service; production architectures combine services where each plays the role its cost shape supports.

    Order events land in Pub/Sub, are persisted to Cloud Storage for replay and audit, are loaded into BigQuery for analytics, are looked up in Bigtable for real-time fraud scoring, and trigger Firestore document updates that mobile clients listen to.

    The exam tests whether the engineer can pick the right service per role, not whether one service replaces all the others. The constraint-first analysis described in this section is the procedure that resolves these scenarios reliably. ---

    Continue with the interactive course

    Track your progress, jump into practice questions and use the Shark AI tutor inside the GCP - Professional Data Engineer learning hub.