Google PDE: Stream Processing with Dataflow and Apache Beam — Study Guide

Part of the Google Professional Data Engineer — Study Guide. Practice with verified answers in the Google exam hub, or take timed practice tests on ExamRoll.io.

Overview

Stream processing on Google Cloud centers on Apache Beam’s unified programming model executed by the Dataflow runner. Beam provides a logical abstraction—pipelines of transforms over PCollections—that decouples your code from execution details such as parallelism, autoscaling, and fault tolerance. In streaming, correctness hinges on time semantics (event time vs processing time), windowing (fixed, sliding, session, global), watermarks, triggers, and handling late data. Operational excellence on Dataflow requires the right worker sizing, autoscaling policy, streaming engine, shuffle choices, idempotent sink design, dead-letter handling, and robust observability.

Apache Beam model and time semantics

Failure modes and trade-offs:

Operating Dataflow for streaming workloads

Deployment, templates, and upgrade strategies

Practical Problem Scenario

NovaTrack Inc. ingests global IoT telemetry from 50,000 temperature sensors and must deliver minute-level aggregates, persist raw data, and surface a real-time dashboard. Occasional malformed messages and out-of-order delivery are expected. The solution must auto-scale, surface bad records for inspection, and support zero-downtime upgrades.

Approach:

  1. Ingestion and time semantics

    • Create a regional Pub/Sub topic and per-region publishers with attributes deviceId and eventTs (RFC3339). Enable ordering keys by deviceId when feasible.
    • Rationale: Pub/Sub provides durable, elastic ingress with at-least-once delivery. Attaching event timestamps at the edge preserves true event time; ordering per device reduces intra-device reordering without central bottlenecks.
  2. Dataflow streaming pipeline with event-time windows

    • Read from a dedicated subscription via PubSubIO, extracting eventTs as the Beam timestamp, falling back to publishTime if missing.
    • Apply FixedWindows of 1 minute with an early trigger at 30 seconds and late firings on each late element; set allowed lateness to 10 minutes and accumulating panes.
    • Rationale: Event-time windows ensure accurate minute aggregates; early firings feed the dashboard with sub-minute freshness; late firings correct aggregates as delayed data arrives. The lateness bound caps state size and cost.
  3. Validation, enrichment, and dead-letter routing

    • Implement a ParDo that parses JSON, validates schema and ranges, and enriches with small static reference data via a side input loaded from BigQuery at job start.
    • Use TupleTags to emit valid records to the main output and failures to a dead-letter PCollection containing payload, error, deviceId, and parse timestamp; write DLQ to a partitioned BigQuery table.
    • Rationale: Side inputs keep reference data in-memory for low latency. Dead-letter capture allows inspection and targeted reprocessing of bad rows without blocking the main flow.
  4. Aggregation and hot-key mitigation

    • Key by deviceId and compute per-minute avg/min/max with CombineFns. For top-N regional metrics, shard by region#N to avoid hot keys, then re-aggregate.
    • Rationale: Combiners minimize shuffle volume and cost; key sharding prevents single-key bottlenecks during regional fan-in.
  5. Sinks and exactly-once effects

    • Write raw validated events and minute aggregates to BigQuery using BigQueryIO with the Storage Write API. Set a stable insert id based on deviceId + eventTs for idempotency in any custom retries.
    • Rationale: Storage Write API provides high-throughput, low-latency ingestion with exactly-once semantics within a stream. Stable ids ensure downstream dedup if replays occur.
  6. Dashboard consistency strategy

    • The dashboard queries partitioned aggregate tables with a lookback of 2 minutes relative to the watermark or a fixed delay of 2x observed availability latency for streaming data.
    • Rationale: BigQuery streaming visibility is eventually consistent; deferring reads slightly prevents missing in-flight rows while retaining near-real-time behavior.
  7. Operations: autoscaling and streaming engine

    • Enable Streaming Engine; set maxWorkers based on expected peak (e.g., 3x average), select a machine type sized for CPU-bound parsing and encryption, and increase boot disk to accommodate transient shuffle.
    • Monitor watermark lag, backlog seconds, CPU, and per-step throughput; alert on sustained lag and DLQ rate spikes.
    • Rationale: Streaming Engine externalizes state/shuffle for elasticity and simpler upgrades; right-sizing and monitoring prevent silent SLO breaches.
  8. Deployment and upgrades with Flex Templates

    • Package the pipeline as a Flex Template with parameters: input subscription, output tables, DLQ table, maxWorkers, and region. For an incompatible change, start the new pipeline targeting the same topic with a new subscription, verify outputs, then drain the old job. Optionally create a Pub/Sub snapshot and seek the new subscription to the snapshot to guarantee no gaps.
    • Rationale: Flex Templates enable repeatable, parameterized deployments. A verified blue/green cutover with drain achieves zero data loss and minimal downtime.
  9. Reprocessing and batch backfills

    • Store compressed Avro files of raw events in Cloud Storage via a side output; run a batch Dataflow pipeline to backfill or reprocess into BigQuery when models or schemas change.
    • Rationale: Durable raw archives support reproducibility and schema evolution without impacting the hot path.

This design yields correct, low-latency aggregates with bounded cost, clear error isolation, strong observability, and safe upgrade paths while handling out-of-order and late data at global scale.


BigQuery Analytics and Warehouse Engineering · All domains · Messaging

Practice these questions → · Timed practice on ExamRoll.io →

Pass the whole exam — not just this question

You found this answer. Get every verified question and explanation in one place, and save hours of prep. Free to start.

Pass your exam →

Browse Google →

Related guides

All-in-one access

One subscription. Every exam.

Every plan unlocks unlimited answer search, practice tests, AI explanations, and the full resource library — in 20+ languages.

Monthly
24.87
Just €0.83/day
Everything included:
  • Unlimited answer search
  • Unlimited practice tests
  • AI-powered explanations
  • Full resource library
  • 20+ languages
  • Weekly content updates
  • Rewards & referrals
  • Priority support
Start free trial

No credit card required*

Best value
12 months
179.87
Just €0.49/daySave 40%
Everything included:
  • Unlimited answer search
  • Unlimited practice tests
  • AI-powered explanations
  • Full resource library
  • 20+ languages
  • Weekly content updates
  • Rewards & referrals
  • Priority support
Start free trial

No credit card required*

✓ Free plan included · ✓ Cancel anytime · ✓ All plans unlock the full product