Loading Academy Hub...
Master Google Cloud Dataflow: Apache Beam programming model, PCollections, PTransforms, ParDo, event time watermarks, late data handling with side inputs and dead-letter queues.
[!NOTE] Google Cloud Dataflow is a fully managed, serverless execution service for Apache Beam pipelines. Beam provides a unified programming model where the exact same pipeline code executes over bounded (batch) or unbounded (streaming) datasets.
map / flatMap).GroupByKey / CoGroupByKey) or Stateful streaming windows on worker local disks—enable Dataflow Shuffle (batch) and Streaming Engine (streaming) to offload shuffle & state storage to Google’s managed service, shrinking worker RAM needs and enabling fast horizontal Worker Autoscaling.Portable Beam): Use Runner v2 whenever mixing Python transforms with Java/Cross-Language I/O connectors (e.g., KafkaIO, BigQuery Storage Write API), using custom Docker worker containers for clean dependency reproducibility.withAllowedLateness(...) and Dead-Letter side outputs (TupleTag)—otherwise malformed Pub/Sub JSON messages trap an unbounded worker retry loop forever, freezing the watermark and halting downstream windowed outputs.Review the production code, company interview Q&As, incident traces, and comprehension quiz inside this lesson.
import apache_beam as beam
from apache_beam.options.pipeline_options import PipelineOptions, StandardOptions
import json
options = PipelineOptions()
options.view_as(StandardOptions).streaming = True
class ParseAndEnrichFn(beam.DoFn):
def process(self, element):
try:
record = json.loads(element.decode('utf-8'))
record['processed_at'] = '2026-03-01T00:00:00Z'
yield record
except Exception as e:
yield beam.pvalue.TaggedOutput('dead_letter', element)
with beam.Pipeline(options=options) as p:
events = p | "ReadPubSub" >> beam.io.ReadFromPubSub(subscription="projects/prod/subscriptions/txns-sub")
parsed, dead_letter = events | "Parse" >> beam.ParDo(ParseAndEnrichFn()).with_outputs('dead_letter', main='parsed')
# Stream valid records to BigQuery
parsed | "WriteToBQ" >> beam.io.WriteToBigQuery(
table="enterprise-lakehouse-prod:finance.fact_transactions",
write_disposition=beam.io.BigQueryDisposition.WRITE_APPEND
)java.lang.OutOfMemoryError: Java heap space. Worker was terminated by monitoring agent.