Prepare and test your skills

Prepare and test your skills

Evaluate and select batch execution frameworks is the decision about where large volumes of historical data are transformed on Google Cloud. The choice depends on workload shape, existing code, and how much cluster management the team will accept. Cloud Dataflow (opens in a new tab) fits Apache Beam code with serverless execution, Spark-based services fit existing Spark logic and visual integration, and BigQuery (opens in a new tab) fits SQL-based transformation directly in the warehouse. Sources, sinks, temporary files, and worker location also affect cost and speed, so the decision includes data locality and format.
Cloud Dataflow is a fully managed, serverless service for running Apache Beam pipelines for both batch and streaming with the same programming model. Data flows from one or more sources through Beam transforms to a destination, and Beam provides windowing, session analysis, and connectors including a connector for BigQuery. Pipelines are written with the Java, Python, and Go software development kits (SDKs), submitted through the command-line interface, SDKs, or JupyterLab notebooks, or deployed as Dataflow templates including Google-provided templates that require no Beam coding.
Dataflow removes cluster operations because Google allocates a pool of Compute Engine worker virtual machines (VMs) when a job starts and deletes the VMs when the job completes or is cancelled. Billing covers the compute resources used while work is processed in parallel across workers. The service autoscales by adding workers when more capacity is needed and shutting workers down when fewer are needed, while improving execution with dynamic work rebalancing and straggler detection and correction. By default Dataflow provides exactly-once processing of every record, with an at-least-once mode for streaming pipelines that can tolerate duplicates to reduce cost and improve latency.
Dataflow pipelines are portable and observable across their lifecycle. Because Dataflow executes Beam pipelines, the same Beam code can later run on a different runner such as Apache Flink or Apache Spark without rewriting pipeline code, and a backup pipeline can run on an on-premises Spark cluster using the Apache Spark Runner. Monitoring is provided through the Dataflow monitoring interface in the Google Cloud console, which shows a graphical representation of the pipeline with progress and execution details per stage, plus centralized logging for all stages. Dataflow also supports highly parallel workloads (opens in a new tab) where independent tasks fan out across many cores and then fan back into downstream systems.
A complete highly parallel pipeline keeps pre-processing, task distribution, and post-analysis in one Dataflow directed acyclic graph (DAG). Existing C++ binaries or other compiled standalone binaries can be included as external code alongside Java, Python, and Go transforms. Security controls for the job include customer-managed encryption keys (CMEK) for pipeline state, firewall rules for the job network, and use of a Virtual Private Cloud (VPC) network.
Cloud Data Fusion is a fully managed data integration service built on the open source Cloud Data Appliance for Hadoop (CDAP) project for building batch and streaming pipelines without writing code. A developer connects sources to transformations, sinks, and other nodes to form a DAG in the Cloud Data Fusion UI. On deployment the Cloud Data Fusion planner transforms that DAG into parallel computations executed as an Apache Spark job on Managed Service for Apache Spark. Connectivity includes Java Database Connectivity (JDBC) drivers uploaded to the instance for reading source databases and loading into destinations such as BigQuery, plus customizable plugins for sources, transforms, aggregates, sinks, error collectors, alert publishers, actions, and post-run actions.
Spark-based batch in this pattern depends on ephemeral clusters orchestrated by an external scheduler. In the documented batch pattern, Managed Airflow validates new files and orchestrates processing in order:
The processed output then flows to a data lake, where data is commonly stored in Cloud Storage in columnar formats such as Parquet and Optimized Row Columnar (ORC) for efficient storage and faster analytical access. Metadata about databases, tables, columns, and partitions is stored in the Hive metastore service supplied by Dataproc Metastore. Rewriting to these managed services fits when existing pipelines use deprecated technologies or when lifting unmodified pipelines would be impractical or cost-prohibitive to maintain.
BigQuery is the analytical data warehouse that both stores historical data and executes SQL-based batch transformation at warehouse scale. When a BigQuery dataset is created, its dataset location (opens in a new tab) is selected as regional, such as Iowa (us-central1), or multi-region, such as United States (US) or Europe (EU). That location controls where data is stored and where locality and availability planning must focus. Warehouses are often terabytes to petabytes and append-only with mostly static older data, so disaster recovery can focus on recovering ingested and processed data and metadata and on re-creating batch pipelines that can simply restart.
How Dataflow reads from and writes to BigQuery directly affects batch performance, quota use, and runtime. Beam's BigQueryIO supports two read methods with different flows and costs. Table export, the default EXPORT method, first invokes a BigQuery export request that writes table data to a temporary Cloud Storage location and then reads that data into the pipeline, which consumes BigQuery export quotas and adds waiting time before processing starts. The DIRECT_READ method uses the BigQuery Storage API to read table rows directly from BigQuery over gRPC for high-throughput reads, which avoids the export step, export quotas, and added runtime.
Writes also split by pattern, with batch pipelines using BigQuery load jobs subject to load-job quotas at the table and project level, and streaming pipelines using streaming inserts or the Storage Write API subject to streaming-insert quotas. Avoid using load jobs to append data thousands of times per day into one table; use a streaming pipeline with streaming inserts or the Storage Write API for near real-time appends instead. Using Google Cloud managed sources and sinks removes capacity management, but Dataflow still depends on sufficient Compute Engine quota to start jobs and autoscale, and on Pub/Sub and BigQuery quotas when they are the source or sink.
Performance, locality, and selection trade-offs determine whether a tuned batch framework can meet its deadline without excess cost. Parallelizable formats such as Avro are usually faster to read than comma-separated values (CSV) files with embedded newlines or compressed files, and geographic proximity of sources, sinks, and temporary files to Dataflow workers affects transfer cost and speed. Calls to external services add per-call overhead, so pipelines should batch multiple elements into single requests where possible. Teams must ensure external systems can sustain parallel load because autoscaling can add workers to a slow external-call step and further pressure that system. These are core issues to address when teams plan a pipeline (opens in a new tab) for production scale.
Locality controls where workers, metadata, and data may move. When a Dataflow job is submitted, the regional endpoint, worker region, and worker zone parameters control where workers deploy and where job metadata is stored. Sources, sinks, and temporary files outside that region can cause data to cross regions. Pub/Sub subscriptions can buffer unacknowledged messages for up to 7 days so backed-up events process with low recovery point objective after pipelines resume. Multiple pipelines can read one topic through separate subscriptions to isolate pulling and acknowledgement for high availability, testing, and updates.
The three execution options differ by code base, management, and workload shape:
| Option | Programming model | Cluster ownership | Choose when |
|---|---|---|---|
| Cloud Dataflow | Apache Beam in Java, Python, or Go, plus templates and notebooks | Serverless; Google provisions and deletes workers | The team has Beam code, needs unified batch and streaming, autoscaling, and exactly-once processing without managing clusters |
| Managed Service for Apache Spark with Cloud Data Fusion | Visual DAG or Apache Spark job, JDBC and plugin connectors | Ephemeral clusters created and deleted per job by Managed Airflow | The team has Spark logic or needs code-free database ingestion and visual integration that compiles to Spark |
| BigQuery | Structured Query Language (SQL) in the warehouse | Fully managed warehouse storage and compute | Schemas are stable and the work is set-based SQL analytics, aggregation, and serving business intelligence directly from tables |
Exam tip: Use DIRECT_READ with the BigQuery Storage API to avoid BigQuery export quotas and extra runtime, and use streaming inserts or the Storage Write API rather than repeated load jobs when appending near real-time data thousands of times per day.
Robust orchestration for batch pipelines means defining the order, dependencies, and retry behavior of jobs that process large historical datasets so re-runs are safe and cost-effective. On Google Cloud, Cloud Dataflow (opens in a new tab) provides fault-tolerant execution, while Cloud Composer, Google Cloud Workflows (opens in a new tab), Cloud Scheduler, and Dataflow data pipelines divide scheduling and sequencing work. Declarative error-handling patterns such as dead-letter queues and idempotent transforms prevent duplicate writes during retries and re-runs.
Orchestration choices for batch pipelines differ by how schedules are defined and what they coordinate. Cloud Composer runs Apache Airflow workflows that can launch Dataflow jobs through the Dataflow Operator, which is one of several Google Cloud Operators available in a Managed Service for Apache Airflow workflow. Dataflow data pipelines create recurrent job schedules and show where resources are spent over multiple job executions, which supports multi-run cost tracking (opens in a new tab). Cloud Scheduler and custom cron processes on Compute Engine provide time-based triggers that start pipelines without managing a full workflow engine.
| Orchestrator | How work is defined | Choose when |
|---|---|---|
| Cloud Composer | Airflow DAG using Dataflow Operator and Google Cloud Operators | The batch process needs dependencies across many tasks and operators |
| Google Cloud Workflows | Workflow of steps in YAML or JSON using syntax, standard library, and connectors | The process sequences loosely coupled services called over HTTP-based APIs |
| Dataflow data pipelines | Recurrent Dataflow job schedule with multi-run cost tracking | The need is repeated batch jobs with visibility into spend across runs |
There is no Dataflow-specific cross-pipeline communication mechanism for sharing data or processing context between pipelines. Data flows from one pipeline instance to durable storage such as Cloud Storage or to an in-memory cache such as App Engine, and then a downstream pipeline reads from that storage. Storage therefore owns the handoff and both pipelines depend on its availability.
Google Cloud Workflows separates the logic that sequences and links services from core business logic. A workflow performs a sequence of operations across multiple systems, waits for all operations to complete, and can be event-driven, which makes service dependencies explicit and observable end-to-end. Choose Workflows when the goal is to write less code to execute loosely coupled services in an order that is defined as a workflow.
A Workflows workflow consists of a series of steps described using the Workflows syntax in either YAML or JSON. Standard library functions and built-in environment variables construct arguments and process responses, while lightweight serverless connectors simplify calling other Google Cloud APIs such as Cloud Run functions or Firestore by handling request formatting. For example, a workflow can use the Cloud Translation API connector to translate files in asynchronous batch mode and save results in a Cloud Storage bucket, or it can run multiple BigQuery query jobs serially one after the other.
A typical lightweight orchestration moves data through an ordered chain of services:
Because the workflow depends on each connector, a failure or delay in any API delays the downstream steps until the workflow completes or handles the error.
Cloud Dataflow execution is separated from pipeline definition by the Apache Beam runner model. A pipeline defined in Apache Beam does not specify how it is executed; the Dataflow runner uploads executable code and dependencies to a Cloud Storage bucket and creates a Dataflow job. Dataflow then allocates a pool of virtual machines to execute the pipeline, so the control plane manages workers while worker VMs process bundles of elements.
Dataflow is fault-tolerant and might retry code multiple times if workers encounter issues. When exactly-once processing is used, the Dataflow service processes every element in the input PCollection by a DoFn instance exactly once, but the service does not guarantee how many times a DoFn is invoked, how distributed elements are grouped, which elements are processed together, or the exact number of DoFn instances created. The service serializes element processing per DoFn instance and might create backup copies of code, so retries and parallel copies are normal lifecycle behavior rather than errors.
A common batch ETL and BI flow shows how these dependencies chain:
Dead-letter queue handling (opens in a new tab) in batch pipelines isolates bad records so one failure does not fail the entire job. A dead-letter queue is a separate output branch that receives elements that fail parsing, validation, or enrichment, while good elements continue down the main output. This looser coupling branches away bad data and allows the pipeline to continue, with the failed records landing in durable storage for inspection, repair, and reprocessing.
Resilient retries complement dead-letter handling for transient problems:
Long-term stability also depends on quotas and worker sizing. High rates of TableService.getTable or tabledata.insertAll calls can exceed BigQuery queries-per-second limits, and in-use IP address and CPU use can exceed Compute Engine limits, so quotas must be monitored and increased before scaling events. To prevent out-of-memory errors, use machine types with more memory, reduce threads per worker, and set a higher number of workers to distribute load and reduce the impact of frequent autoscaling.
Exam tip: Increase the acknowledgment deadline to stop premature redelivery during slow processing, but use a dead-letter branch to stop permanently bad records from retrying forever.
Idempotent design means a batch pipeline can run again over the same historical input without creating duplicates or corrupting state. Apache Beam ParDo and DoFn objects are designed as small, independent entities that may run on many machines with no knowledge of each other. The safest pattern is pure functions that do not depend on hidden or external state, have no observable side effects, and are deterministic. Pure functions fit parallel distribution because any retry or copy produces the same result for the same input element.
Non-idempotent side effects break this guarantee when Dataflow retries or duplicates execution. Manual side effects such as creating temporary files with non-unique names can collide when backup copies run, and per-element calls to external services can write twice if a bundle is retried. To stay safe, generate deterministic keys for grouping, batch external checks such as BigQuery getTable calls per bundle or cache them in worker memory, and design sinks to tolerate replays through keys, merge logic, or checks before insert. Test with realistic batch volume including total element count, element size, and key count, in both steady state and large-backlog recovery, so retry and re-run behavior is verified before production.
Optimize pipeline performance and resource efficiency means moving heavy grouping work off workers and removing bottlenecks outside the pipeline code. In Dataflow, Dataflow shuffle (opens in a new tab) partitions and groups data in the service backend instead of on worker virtual machines (VMs), which lowers worker resource use and improves scaling and recovery. Batch jobs use Dataflow shuffle by default, while streaming jobs use a different mechanism called streaming shuffle.
Dataflow shuffle is the base operation behind transforms such as GroupByKey, CoGroupByKey, and Combine. The Dataflow shuffle operation partitions data by key and groups values for each key in a scalable, efficient, and fault-tolerant manner. Data flows from worker VMs to the Dataflow service backend for the shuffle phase, then back to workers for downstream processing. Because the service backend holds the intermediate grouped data, workers do not need to store and exchange all shuffle data among themselves.
Performance and resource benefits of service-based shuffle come from offloading shuffle work to the Dataflow service, which speeds up most batch pipeline types. The reduction covers central processing unit (CPU), memory, and Persistent Disk storage on the worker VMs. Better Horizontal Autoscaling and fault tolerance follow directly from workers no longer holding shuffle data.
When autoscaling removes VMs earlier, the job depends less on keeping extra workers alive just to retain intermediate data. When a worker fails, the job continues because the grouped data remains available in the service backend rather than being lost with that VM.
Configuration requirements and regional rules control whether a batch job can actually use Dataflow shuffle. Dataflow shuffle is available in all regions where Dataflow is supported, though performance can differ between regions. Workers must be deployed in the same region as the Dataflow job, and the job must set the region pipeline option so Dataflow can automatically select a zone. Do not specify the zone pipeline option for shuffle jobs.
If the zone option points outside supported regions, the Dataflow job returns an error, and an incompatible combination of region and zone prevents the job from using Dataflow shuffle. For Python pipelines, Dataflow shuffle requires Apache Beam software development kit (SDK) for Python version 2.1.0 or later. In some cases workers receive internal Internet Protocol version 6 (IPv6) addresses from ranges such as 2600:2d00::/28 to enable optimized, direct communication from the worker network to the Shuffle service backend.
Exam tip: Batch jobs use Dataflow shuffle by default, while streaming jobs use streaming shuffle; for batch shuffle jobs set region, not zone, or the job cannot use Dataflow shuffle.
Disk sizing, pricing, and execution tradeoffs determine whether a shuffle job runs reliably without overpaying for workers. Dataflow shuffle batch jobs use a default boot disk size of 25 GB per worker, which is much smaller than the 250 GB default for non-shuffle batch jobs. Each worker VM uses part of that 25 GB for the operating system, binaries, logs, and containers, so jobs that write significant local disk data can exceed remaining capacity and fail. Jobs with heavy disk input/output (I/O) can also run slowly on the small disk because Persistent Disk performance scales with disk size.
To run larger or I/O-heavy shuffle jobs, set a larger size with the --disk_size_gb pipeline option. Most worker savings come from offloading work to the service, so Dataflow shuffle carries a separate service charge even as worker VM costs fall, which is a central cost optimization (opens in a new tab) tradeoff. Execution times can vary from run to run, so pipelines with strict deadlines should include buffer time before the deadline.
Planning sources, sinks, and external calls for scale means ensuring systems outside the pipeline do not limit throughput. Dataflow runs pipeline stages (opens in a new tab) in parallel across multiple workers, but systems outside the pipeline can set the upper bound on throughput. Network location and data format also affect how fast workers can read and write.
Calling external services from inside transforms adds per-call overhead that lowers efficiency, and many native Beam input/output (I/O) transforms such as BigQueryIO (opens in a new tab) already batch elements into fewer requests. External services may also enforce daily quotas or per-second rate limits, and autoscaling can make the problem worse by adding workers that place even more pressure on the struggling service. Design the pipeline workflow (opens in a new tab) to batch external calls and to limit concurrent calls to levels the external system can sustain.
Quotas, limits, and capacity for batch jobs determine whether a tuned batch job can start and scale. Each Google Cloud project can run at most 25 concurrent Dataflow jobs by default, or 125 per organization when organization-level quotas are used. Each Dataflow job can use up to 2,000 Compute Engine instances, or up to 4,000 instances for a batch job using service-based Dataflow shuffle when no worker zone override is set. Dataflow batch jobs are cancelled after 10 days.
Each project also receives shuffle slots per region that cap how much data can be shuffled concurrently, with 16 slots handling approximately 10 TB of concurrent shuffle data. Larger regions provide more slots, including 640 slots in us-central1, europe-west1, europe-west4, and us-east1, 512 slots in northamerica-northeast1, and 384 slots in us-west1, while many smaller regions provide 16 to 64 slots. Compute Engine quota is enforced per region for CPUs, in-use Internet Protocol (IP) addresses, Persistent Disk, and Regional Managed Instance Groups, and insufficient quota blocks startup or autoscaling. Dataflow deploys workers as a Regional Managed Instance Group that requires one instance group, one instance template, and one regional managed instance group per job, and a batch job is cancelled if that managed group is missing for more than one hour.
Use Cloud Dataflow for Apache Beam code that needs unified batch and streaming, autoscaling, and exactly-once processing without managing clusters, use Managed Service for Apache Spark with Cloud Data Fusion for existing Spark logic or code-free database ingestion with a visual directed acyclic graph (DAG) that compiles to Spark, and use BigQuery for stable-schema set-based Structured Query Language (SQL) analytics, aggregation, and serving business intelligence directly from the warehouse.
Table export is the default EXPORT method that first invokes a BigQuery export request that writes table data to a temporary Cloud Storage location and then reads that data into the pipeline, which consumes BigQuery export quotas and adds waiting time before processing starts. DIRECT_READ uses the BigQuery Storage API to read table rows directly from BigQuery over gRPC for high-throughput reads, which avoids the export step, export quotas, and added runtime.
Set the region pipeline option so Cloud Dataflow can automatically select a zone and do not specify the zone pipeline option, because an incompatible region and zone combination prevents the job from using Dataflow shuffle. Dataflow shuffle batch jobs use a default boot disk size of 25 GB per worker compared with 250 GB for non-shuffle batch jobs, so set a larger size with the disk_size_gb pipeline option for jobs with heavy local disk input and output.
A data engineering team manages a daily batch pipeline orchestrated by Cloud Composer that processes terabytes of transactional log files from Cloud Storage into partitioned BigQuery tables. Recently, transient worker pod evictions and network timeouts have triggered task retries, resulting in duplicate data rows in BigQuery and failed task executions caused by exhausted worker disk space.
You need to re-architect the workflow orchestration to ensure fault tolerance, prevent duplicate records during task retries (idempotency), and prevent worker resource exhaustion.
Which architectural strategy should you implement?
Configure tasks with WRITE_APPEND mode and attach an on_failure_callback that executes a downstream script to scan and delete all duplicate records across the entire BigQuery table if any failure occurs.
Use deprecated Airflow operators like BigQueryExecuteQueryOperator to stage records into the Airflow metadata database, then invoke the Airflow Web Server API to trigger manual transaction rollbacks upon task failure.
Download the daily Cloud Storage files into the Airflow worker's local storage directory, deduplicate the records in Python worker memory, and insert records into BigQuery using WRITE_APPEND while tracking retry state via top-level Variable.get calls.
Configure BigQuery jobs to write to specific partition decorators using WRITE_TRUNCATE or execute SQL MERGE statements, load data directly from Cloud Storage to BigQuery without staging on local worker disks, and configure declarative task retries with exponential backoff.
Last updated