Prepare and test your skills

Prepare and test your skills

Optimizing resources means sizing compute and storage to actual business demand and letting capacity expand and contract automatically. Elastic compute comes from Compute Engine, Cloud Run, Dataflow, Managed Service for Apache Spark (opens in a new tab), and BigQuery, while cost guardrails come from Cloud Storage, Persistent Disk, and Cloud Monitoring with billing alerts. The practice pairs right-sizing, autoscaling, tiered storage, colocation of compute with data, and budgets with discounted pricing.
Right-sizing matches machine shape and container size to observed workload before enabling elasticity. Compute Engine provides machine type recommendations that analyze CPU and memory use and suggest a smaller or better-fitted type, and custom machine types let teams provision CPU cores independently of memory. For container jobs on Cloud Run, charges are based on on-demand CPU, memory, and request count, so teams start with default limits and increase only after observing performance. Separation of layers keeps bytes in the storage layer in systems such as Cloud Storage, BigQuery storage, Cloud SQL, Spanner, or Bigtable, while the computation layer loads data, processes it, and writes results back. Keeping the layers on separate platforms in the same zone and region lowers latency, outbound transfer cost, and I/O operations and avoids paying for idle compute when only storage is needed.
Autoscaling adds capacity when load rises and removes it when load falls, which handles traffic gracefully while reducing cost during quiet periods. Autoscaling in Compute Engine applies to stateless managed instance groups (MIGs), where the autoscaler creates or deletes virtual machine (VM) instances based on utilization; stateful MIGs cannot be autoscaled because each instance preserves unique state. Cloud Run scales regional services automatically and load-balances traffic across multiple zones, so a zone outage does not lose data or stop jobs, while a region outage pauses jobs until Google resolves it.
| Hosting option | Configuration flexibility | Management responsibility |
|---|---|---|
| VMs on Compute Engine | High, including custom machine types and simultaneous multithreading settings | Team manages VMs, patching, scaling, and availability |
| Containers on Google Kubernetes Engine (GKE) | High, with automated deployment and scaling of containerized apps | Team manages clusters and workloads, platform automates orchestration |
| Serverless on Cloud Run | Lower, deployed to a preconfigured platform with CPU and memory limits | Minimal, platform manages provisioning, load balancing, and scale to demand |
Choose VMs when licensing or operating-system access requires control, such as bringing your own Windows Server license or disabling simultaneous multithreading to reduce vCPUs per core from 2 to 1. Choose GKE when containerized workloads need orchestration across zones, and choose Cloud Run when the priority is data logic rather than infrastructure. Spot VMs cost significantly less with the same performance but Compute Engine can preempt them, so they fit fault-tolerant batch jobs without strict service objectives, not latency-sensitive pipelines.
Capacity planning turns forecasted demand into a concrete footprint with redundancy and cost estimates. Forecasting starts from user count and request rate, historical trends and seasonal variation, spikes during special events, and business growth such as expansion to new geographies. Teams estimate MIG size, VM machine type, and persistent disk count and type with the Google Cloud Pricing Calculator, then add N+1 redundancy where every component has at least one spare beyond the minimum. Resource efficiency is measured with load tests under normal and peak conditions and retested regularly because efficiency degrades under extreme load.
Capacity must be validated and protected in order:
Quotas are per-project limits that can typically be raised, while system limits are fixed values that cannot be changed. When a task exceeds its quota, the system blocks access and the task fails. Dataflow shows how they combine: up to 3,000,000 requests per minute per project, up to 25 concurrent jobs by default and up to 125 per organization, and up to 2,000 Compute Engine instances per job, or up to 4,000 for Streaming Engine streaming jobs or service-based Shuffle batch jobs with no worker zone specified.
Tiered storage places data in the class that matches retention and access frequency. Cloud Storage offers Standard, Nearline, Coldline, and Archive, where the colder classes cost less for infrequently accessed data. Lifecycle policies automatically transition objects to lower-cost classes or delete them by age and access patterns, while Autoclass moves objects between classes as access changes. Durability choices also change cost: regional buckets replicate synchronously across zones, dual-region and multi-region buckets store data redundantly in at least two locations, and zonal Persistent Disk is lowest cost while regional Persistent Disk synchronously replicates between two zones. Colocation reduces cost further by placing compute in the same region as data to avoid egress, such as moving a bucket accessed from us-central1 out of us-east1.
Exam tip: BigQueryIO EXPORT moves data through temporary Cloud Storage and consumes export quotas, while DIRECT_READ reads directly through the BigQuery Storage API over gRPC to avoid export quotas and reduce runtime.
Continuous efficiency detects waste, attributes cost to owners, and rightsizes without breaking performance. Cloud Monitoring collects metrics from Compute Engine, GKE, and Cloud Run into dashboards for CPU, memory, throughput, latency, and error rates, while Cloud Logging centralizes logs and triggers alerts on anomalies. Active Assist, including Recommender, analyzes history at no additional cost to surface idle VMs and rightsizing opportunities. Billing data flows from metered usage to Cloud Billing reports and the FinOps hub, and detailed export to BigQuery enables SQL aggregation by label, project, service, or time. A slot is a virtual compute unit that BigQuery uses to execute SQL queries, and business-critical work uses capacity-based billing with a reservation of at least 50 slots, while variable work can remain on shared on-demand capacity. Predictable work then shifts to committed use discounts (CUDs) for one-year or three-year terms.
Continue with this study guide: Optimizing resources
Designing automation and repeatability means defining workflows as code that run in the same order every time and trigger reliably across services. The Managed Service for Apache Airflow evaluates directed acyclic graph (DAG) files to build execution graphs, Cloud Scheduler invokes jobs on unix-cron intervals, and event-driven chaining uses Pub/Sub, Dataflow, and Workflows (opens in a new tab) for serverless and batch pipelines. Together they separate time-driven schedules from event-driven triggers while keeping runs idempotent and observable.
A directed acyclic graph (DAG) is a Python workflow file that defines tasks and dependencies in an order that never loops back. A DAG definition binds workflow identity, owner, start date, and schedule together, tasks such as DummyOperator are created inside that context with a unique task_id, and the bitshift operator >> connects them so control flows from the upstream task on the left to the downstream task on the right. A list such as [task_1, task_2] means the workflow depends on both tasks in parallel, while start >> [task_1, task_2] means control flows from start to both tasks at the same time. The pattern start >> [task_1, task_2] >> some_other_task >> [task_3, task_4] >> end executes in a fixed order:
start to both tasks, which run in parallel.some_other_task to both tasks, which run in parallel.end, which closes the workflow.This structure preserves acyclic properties because no downstream task points back upstream. Narrowing parallel branches back to a single task before fanning out again prevents ambiguous ordering.
TriggerDagRunOperator is the operator that triggers a child DAG run from within a parent controller DAG. The parent task defines trigger_dag_id and a conf dictionary that flows from the parent to the triggered run as configuration, which requires two separate DAG files in the same Managed Airflow environment. The child DAG defines DAG_NAME with schedule_interval="None", so the child does not run on its own schedule and runs only when the parent triggers it. Pausing an Airflow DAG stops the scheduler from launching new runs while a failure is investigated, which prevents additional failed runs and downstream tasks from consuming partial data. Checking for DAG errors moves from static errors to runtime behavior: check syntax errors in the Airflow web interface, check that runs are scheduled at the correct time, wait for runs in the Managed Airflow (Gen 3) environment and verify success, then troubleshoot any failed run by opening the Executions tab, reviewing logs, applying the fix, and waiting for a successful rerun before unpausing.
Exam tip: The value of trigger_dag_id must exactly match the dag_id of the DAG to trigger, and the triggered DAG uses schedule_interval="None" so it waits for the trigger.
An Airflow operator defines the type of work a task performs, while a task is a single instance of that operator inside a DAG. BashOperator runs command-line programs on an Airflow worker, which includes gcloud, bq for BigQuery, and kubectl for GKE pods. PythonOperator runs arbitrary Python code for custom transformation or branching, while Google Cloud operators such as BigQueryInsertJobOperator execute natively in managed services and transfer operators move data between BigQuery and Cloud Storage. Cloud Scheduler is a fully managed, time-driven scheduler where each job defines a name unique in the same region, a region such as us-central1, a frequency in unix-cron format such as */5 * * * * for every 5 minutes, and a target such as Pub/Sub or HTTP. Configuration follows an ordered workflow: create a service account for authentication, grant impersonation and target permission such as roles/workflows.invoker, define schedule and target with time zone, then force the job to run and verify delivery. Retry policy with attempt deadline and retry count can deliver duplicates, so downstream logic must be idempotent.
Scheduling selection starts by identifying whether work is event-driven, time-driven, or both. An event is a state change such as a file arriving in Cloud Storage, so arrival can trigger immediate processing, while time-driven scheduling loads or aggregates on a clock such as daily reports. Event-driven chaining often uses a Pub/Sub topic that decouples producers from executors, where agents in VMs pull messages, start pipelines, and wait for completion; subscriptions can buffer unacknowledged messages for up to 7 days. Dataflow runs Apache Beam batch and streaming jobs by allocating worker VMs, distributing data in parallel, autoscaling and rebalancing work, then deleting VMs on completion with exactly-once processing by default. Cloud Data Fusion builds pipelines through a graphical interface where sources connect to transformations and sinks, and the planner executes the graph as an Apache Spark job.
| Scheduler | Best fit | Scheduling method |
|---|---|---|
| Dataform | Tested, version-controlled SQL collections in BigQuery after raw load | Time-driven |
| Workflows | Chaining HTTP-based microservices with very low latency | Event-driven and time-driven |
| Managed Service for Apache Airflow | Durable extract-transform-load and MLOps across heterogeneous systems | Time-driven and event-driven |
| Cloud Scheduler | Invoking batch, streaming, or infrastructure operations on intervals | Time-driven |
Continue with this study guide: Designing automation and repeatability
Organizing workloads based on business requirements means buying and assigning dedicated query compute to meet performance, cost, and isolation needs. Compute is measured in slots, which are virtual compute units that execute SQL queries and load, export, query, and copy jobs. BigQuery separates compute, memory, and storage into independently managed services, so choosing slot capacity is separate from storing data, and Managed Service for Apache Airflow (opens in a new tab) orchestrates ephemeral processing around those stores.
Slots as isolated compute capacity are units of computational power that run queries independently of stored data volume. Storage scales to dozens of petabytes in a distributed file system where data is compressed, encrypted, and replicated, while compute slots connect to memory through a remote distributed service over a petabit network. Google manages all underlying infrastructure and automatically decides how many slots each query uses based on data volume, complexity, and available capacity. Because storage growth does not consume query slots, adding slots increases concurrency and throughput without resizing storage. A practical reference is reserving about 4,000 slots to run about 100 medium-complexity queries concurrently, then adjusting as concurrency grows.
Reservations and assignments are two linked objects that guarantee capacity for assigned workloads. A reservation is a pool of slots created in an administration project and shared by assigning projects, folders, or organizations to it. Queries issued from an assigned project flow to the assigned reservation for execution, so production work does not compete with ad hoc work in the shared on-demand pool. Each reservation combines baseline slots that are always allocated with autoscaled slots added or removed with demand, starts at a minimum of 50 slots up to regional quota, and uses a slot budget as the maximum cost cap. A reservation with assignments cannot be deleted until its assignments are removed, and reservation assignments route work by the most specific assignment where project beats folder beats organization.
On-demand versus capacity-based billing is the choice between paying for bytes scanned from a shared pool and paying for dedicated slots in a reservation. The billing model applies per project, so the same organization can run some projects on on-demand and others on capacity-based at the same time and can switch at any time. There is no charge for bytes processed when a query runs under the capacity-based model.
| Model | How capacity is obtained | Cost basis |
|---|---|---|
| On-demand pricing | Queries draw from the BigQuery shared pool with fixed per-project capacity | Pay per TiB scanned, with 10 MiB minimum per query |
| Capacity-based pricing with Editions | Queries draw from dedicated baseline plus autoscaled slots in an assigned reservation | Pay for slot-hours consumed, with optional monthly or annual commitments |
On-demand fits variable, exploratory, or low-volume work because no capacity is provisioned, but it is capped at 2,000 slots per project and shares performance with other tenants. Capacity-based fits enterprise warehousing, reporting, and extract-load-transform workloads with many concurrent queries because dedicated slots isolate performance and support higher concurrency.
Exam tip: On-demand projects are capped at 2,000 slots per project; exceeding that capacity requires switching to the capacity-based model with reservations.
Interactive queries execute as soon as possible and are the default for low-latency analysis, while batch queries queue and start when idle resources are available in the shared pool or reservation. A BigQuery query flows through an ordered path: first BigQuery builds an execution tree of parallel stages, then stages exchange intermediate data through a fast distributed shuffle tier, then BigQuery generates a query plan, then workers monitor progress and dynamically adjust the plan, then BigQuery writes results to persistent storage that enables cached repeat runs. Batch processing with Dataflow and ephemeral Spark prioritizes parallel throughput over single-query latency, where Managed Airflow validates new files in Cloud Storage, starts an ephemeral Spark cluster, processes extract-transform-load into Parquet or optimized row columnar (ORC), stores metadata in Dataproc Metastore, then deletes the cluster. Reservations isolate workloads by assigning pools such as prod and test so test jobs do not compete for production capacity, while unused dedicated slots are automatically shared with other workloads that need them.
Continue with this study guide: Organizing workloads based on business requirements
Monitoring and troubleshooting processes means using metrics, logs, traces, and admin views to explain performance, cost, and security behavior. BigQuery slot usage, Dataflow stage health, and audit activity flow into Cloud Monitoring, Cloud Logging, and the BigQuery admin panel that answer different questions. Together they separate slow query design from contention for shared capacity and separate code failures from quota or permission blocks.
How BigQuery executes queries explains where capacity is spent and why repeat runs can differ. A slot is a unit of computational capacity, and when a query starts BigQuery builds an execution tree that divides work into stages that run in parallel across workers. Stages exchange intermediate data through a fast distributed shuffle tier, BigQuery can dynamically adjust the plan as results arrive, and results are written to compressed, encrypted, replicated storage that allows the next identical query to be served from cache. Slot reservations are buckets of dedicated capacity that isolate important workloads from shared-pool contention, and scaling means changing reserved slots rather than resizing nodes. Key Cloud Monitoring signals include slots used by project, by project and job type, and across projects in reservations, plus total slots available, query count, and non-cached execution times at 5th, 50th, 95th, and 99th percentiles. Dataflow diagnostics use backlog_bytes for unprocessed input, backlog_elements for pending elements, processing_parallelism_keys for hot-key skew, and system_lag and per_stage_system_lag for slow stages.
Budget planning creates the baseline that forecasts are measured against. Best practice is to use a single billing account across projects, assign each project a billingcode metadata label to allocate cost between cost centers, and set budgets with alert thresholds. A budget can cover a single project, all projects in a folder, or all projects for a cost center, and initial estimates can be built with the Pricing Calculator. Billing data flows from Cloud Billing to BigQuery export tables where queries aggregate charges and credits by label and service for chargeback, while console billing reports support multi-dimensional views and anomaly detection flags spikes. Predictive budget alerts trigger email notifications on actual or forecasted spend, such as alerting when forecasted spend reaches 120% of budget, and budgets can also publish to programmatic endpoints for automation.
Exam tip: Budget alerts notify on consumption against budgets you define for each project, while billing notifications from Essential Contacts notify on pricing updates, errors, and credits.
Checking quota usage means comparing configured maximums against consumed resources before workloads fail. In the console the Quotas page finds service-specific quotas, while gcloud compute project-info describe shows project-wide quotas and gcloud compute regions describe shows regional use. A gcloud command that exceeds quota outputs quota exceeded and returns exit code 1, an API request returns HTTP 413, and a BigQuery operation returns HTTP 403 Forbidden with a JSON body containing reason and message. Quota types define what is restricted: resource quotas limit maximum resources that can exist, rate quotas limit API requests in a period, and quotas can be zonal, regional, or global.
| Error reason | Meaning | Response |
|---|---|---|
| rateLimitExceeded | Short-term burst limit reached | Retry after seconds with exponential backoff |
| quotaExceeded | Longer-term quota exhausted | Wait 10 minutes or longer, then optimize or request increase |
Daily quotas replenish incrementally over 24 hours, and consistently reaching quotaExceeded means treating project quotas, organizational constraints, and system limits as separate layers. The bq show -j JOB_ID command and INFORMATION_SCHEMA.JOBS views expose slot-millisecond consumption, spilled bytes, queue times, and error codes, while Cloud Audit Logs record who initiated each operation. Quota-specific monitoring uses the Consumer Quota resource type, and services that support quota metrics include Compute Engine, Dataflow, Spanner (opens in a new tab), Pub/Sub, and Cloud Logging, while App Engine and Cloud SQL do not.
Managing workloads means configuring jobs for performance, monitoring them during execution, and controlling the compute that powers them. The Dataflow monitoring interface shows running jobs and jobs from the last 30 days with job graph, execution details, metrics, cost, and logs, where data flows from pipeline code and staged artifacts to workers and then to sources and sinks. Troubleshooting follows an ordered path: check pipeline status, inspect job error messages and step logs, determine whether failure happened during graph construction, job validation, or worker execution, then fix slow steps using lag signals. With on-demand billing queries use a shared pool up to 2,000 slots per project with no setup, while capacity-based billing requires reservations with a minimum of 50 slots assigned to projects, folders, or organizations. Cloud Billing budgets are alerts-only controls that track actual and forecasted costs, while quotas block or throttle use after the limit and defensive SQL such as SAFE_CAST(), SAFE_DIVIDE(), and ASSERT prevents runtime failures from bad values.
Continue with this study guide: Monitoring and troubleshooting processes
Maintaining awareness of failures and mitigating impact means keeping progress and data outside ephemeral compute so a failure resumes from the last good point. Cloud Storage holds backups, exports, and transaction logs as replayable sources, persistent disks and snapshots hold VM state, and managed databases hold replicated table state. Together checkpoints, durable copies, and replay steps let a pipeline restart without starting from the beginning in resilient single-region environments (opens in a new tab) or across regions.
Checkpointed processing writes regular progress markers to durable storage so replacement VMs can resume after preemption. Batch workloads and long-running training tolerate interruptions and can run on cost-effective Spot VMs and preemptible instances, which Compute Engine can stop when capacity is needed elsewhere. When new VMs launch, the job reads the last checkpoint and continues after a short pause. A replayable source is a durable copy such as a full backup followed by transaction logs that can be re-applied in order to rebuild state. In the recovery topology, backup files and logs flow from the on-premises database to a Cloud Storage bucket, then from the bucket to the recovery instance in Google Cloud. A typical recovery follows a fixed order: start a minimally sized instance from a matching custom image, set auto-delete on disks to false, apply the latest backup from Cloud Storage, replay the latest logs, replace the minimal instance with a larger production instance, then redirect clients. For analytics, storing time-period data in different tables limits restore to the affected slice, and BigQuery snapshot decorators recover state only when corruption is caught within 7 days.
Resource scope determines which failure a workflow survives. Compute Engine VMs and zonal Persistent Disk operate in one zone, regional MIGs and App Engine spread across zones in one region, and Google-managed multi-regional services distribute within and across regions. A zone is a single-failure domain.
| Resource scope | Failure domain | Resilience guarantee |
|---|---|---|
| Zonal resources | Single zone | Unavailable until that zone recovers |
| Regional resources | Multiple zones in one region | Resilient to loss of one zone |
| Multi-regional resources | Multiple regions | Designed to function after loss of one region |
Cloud Storage, BigQuery, Spanner, Firestore, and Cloud KMS are multi-regional examples. If one region fails, only customers solely in that region are impacted, while multi-regional users are not. The regional deployment archetype runs instances in two or more zones with data replicated synchronously across zones, where traffic flows from users to a regional external load balancer to frontends to backends to a database replicated across zones. A managed instance group (MIG) keeps the target number of identical VMs running from an instance template, and when a VM fails its health check the MIG deletes and recreates it.
Exam tip: Regional resources survive a zonal outage but fail in a regional outage; only multi-regional resources or a separate failover region survive loss of an entire region.
The failover pattern for regional outages keeps a passive replica stack in a second region. The primary region handles active processing while the failover region holds data copies and lower-capacity compute. Recovery follows an ordered sequence: first activate the failover stack and scale standby to production, then promote the database replica to primary using snapshots or managed multi-regional storage, then use Cloud DNS routing to route traffic to the failover load balancer. Recovery readiness controls cost and recovery time:
| Pattern | What runs before failure | Restart behavior |
|---|---|---|
| Cold | Minimal resources, images, backups, templates | Deploy from template, restore backup and logs, point DNS |
| Warm | Small database with replication, snapshots, reservations | Resize database, create instances from snapshots, point DNS |
| Hot | Both environments serving production | Reroute DNS and promote replica if not automatic |
Synchronous replication requires the primary to wait for standby acknowledgment in the same region, which increases write latency but gives strong consistency and near-zero loss. Asynchronous replication lets the primary acknowledge first and send later to a distant region, which keeps latency low but can lose recent writes. Managed restart combines onHostMaintenance set to MIGRATE for live migration and automaticRestart set to true for crash restart, both defaults, but neither replaces redundancy across zones and regions.
Centralized health observability shows Failed Sources and Failed Parsers plus Last Event Time and Last Ingested timestamps, refreshed about every 15 minutes. Completeness catches volume anomalies, freshness catches latency when the gap exceeds 30 minutes, and consistency catches parsing failures; automated alerting uses Metric absence to trigger when logs stop flowing, for example for 60 minutes. Data quality validation checks types, formats, ranges, and distributions in code and in Knowledge Catalog, while BigQuery anomaly detection flags statistical outliers that can indicate data poisoning. Automated recovery rebuilds from safe checkpoints: schedule exports of BigQuery tables to Cloud Storage using Avro with SNAPPY or JSON with GZIP, then on corruption create a new table and load only uncorrupted data. Memorystore for Redis Standard Tier replicates from primary to replica, where limited-data-loss manual failover aborts when bytes pending replication is 30 MB or greater, while force-data-loss proceeds and can lose more. Cloud SQL advanced disaster recovery promotes a cross-region direct read replica, where replica failover promotes immediately with possible loss equal to lag, while switchover drains lag to zero for zero loss.
Continue with this study guide: Maintaining awareness of failures and mitigating impact
rateLimitExceeded for short-term burst limits retried with exponential backoff and quotaExceeded for longer-term exhaustion requiring a longer wait and workload analysis.Spot virtual machines on Compute Engine fit fault-tolerant batch jobs without strict service objectives because they cost significantly less with the same performance but Compute Engine can preempt them. They do not fit latency-sensitive pipelines. Checkpointed processing writes regular progress markers to durable storage so replacement virtual machines can resume from the last checkpoint after preemption.
On-demand pricing in BigQuery draws queries from the shared pool and charges per TiB scanned with a 10 MiB minimum per query and a cap of 2,000 slots per project. Capacity-based pricing draws queries from dedicated baseline plus autoscaled slots in an assigned reservation with a minimum of 50 slots and charges for slot-hours consumed with no charge for bytes processed.
Autoscaling on Compute Engine applies to stateless managed instance groups where the autoscaler creates or deletes virtual machine instances based on utilization. Stateful managed instance groups cannot be autoscaled because each instance preserves unique state.
Downstream logic must be idempotent because a Cloud Scheduler retry policy with attempt deadline and retry count can deliver duplicates. Each Cloud Scheduler job defines a name unique in the same region, a region, a frequency in unix-cron format with a configured time zone, and a target such as Pub/Sub or HTTP.
Last updated