Streaming Data Pipeline Design with Dataflow and Pub/Sub

ADP By islever Editorial Last updated

Design and implement simple data pipelines.

Short answer

B Use Dataflow to create a streaming pipeline that reads the data from Pub/Sub, processes the data, and writes it to BigQuery using the streaming API.

Question

You work for a gaming company that collects real-time player activity data. This data is streamed into Pub/Sub and needs to be processed and loaded into BigQuery for analysis. The processing involves filtering, enriching, and aggregating the data before loading it into partitioned BigQuery tables. You need to design a pipeline that ensures low latency and high throughput while following a Google-recommended approach. What should you do?
  1. Use Cloud Composer to orchestrate a workflow that reads the data from Pub/Sub, processes the data using a Python script, and writes it to BigQuery.
  2. Use Dataflow to create a streaming pipeline that reads the data from Pub/Sub, processes the data, and writes it to BigQuery using the streaming API. Correct Answer
  3. Use Dataproc to create an Apache Spark streaming job that reads the data from Pub/Sub, processes the data, and writes it to BigQuery.
  4. Use Cloud Run functions to subscribe to the Pub/Sub topic, process the data, and write it to BigQuery using the streaming API.

Key Takeaways

The main trap is confusing orchestration (Composer) or batch/cluster-based processing (Dataproc) with true serverless stream processing (Dataflow), which is Google's recommended approach for this specific workload.

This question tests the design of a low-latency, high-throughput streaming pipeline using Google Cloud services. The correct solution leverages Dataflow for real-time processing from Pub/Sub to BigQuery.

Common mistake: Candidates often choose Cloud Composer (A) thinking 'orchestration' means 'processing', but Composer only manages jobs; it does not process streams itself. Others may pick Dataproc (C) assuming Spark is always the standard for big data, ignoring the operational complexity and Google's preference for Dataflow in streaming contexts.

Expert Analysis

The scenario requires a streaming data pipeline with low latency and high throughput, specifically involving filtering, enriching, and aggregating real-time player activity from Pub/Sub into BigQuery. Google Cloud's recommended service for serverless, scalable stream processing is Dataflow. Dataflow natively integrates with Pub/Sub via Apache Beam, allowing for efficient windowing, late-data handling, and direct streaming writes to BigQuery using the streaming API.

Option B is correct because Dataflow is designed for this exact pattern: it reads directly from Pub/Sub, performs complex transformations (filtering, enrichment, aggregation) in-memory with high efficiency, and writes to BigQuery. It autoscales automatically to handle throughput spikes common in gaming scenarios.

Option A (Cloud Composer) is incorrect because it is an orchestration tool, not a stream processor. While it can trigger workflows, it does not provide the low-latency, continuous processing required for real-time streaming data; it is better suited for batch or scheduled tasks.

Option C (Dataproc) involves managing Spark clusters. While Spark Structured Streaming can process data from Pub/Sub, it requires significant cluster management overhead and is generally less cost-effective and more complex to operate than the fully managed Dataflow for this specific use case. Google recommends Dataflow over Dataproc for pure streaming analytics unless specific custom Spark libraries are needed.

Option D (Cloud Run functions) is unsuitable for high-throughput streaming due to cold starts, concurrency limits, and the lack of native stateful aggregation capabilities found in stream processing engines like Beam/Dataflow. It is better for event-driven, lightweight tasks rather than continuous high-volume data pipelines.

Exam Strategy

When asked about 'streaming' and 'real-time' processing on Google Cloud, prioritize Dataflow unless there is a specific constraint requiring on-prem integration or custom Spark code. Remember that Composer is for orchestration (scheduling dependencies), not execution. For high-throughput, serverless stream processing, Dataflow is almost always the correct architectural choice over Dataproc due to lower operational overhead and better integration with Pub/Sub.

Frequently Asked Questions

Why not use Cloud Composer for streaming data?

Cloud Composer is an orchestrator, meaning it schedules and monitors jobs. It does not have built-in capabilities to continuously ingest and process streaming data in real-time. It is best used for batch workflows.

Is Dataproc ever better than Dataflow for streaming?

Dataproc might be chosen if you need to use specific open-source libraries not supported by Dataflow/Beam or if you require tight control over the Spark cluster configuration. However, for most standard streaming ETL tasks, Dataflow is more scalable and easier to manage.

More ADP FAQ →

Discussion 1 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 1

  1. Terralogiq 👍 1 Answered B
    Dataflow is Google's recommended approach for streaming pipelines like this case, it's built for exactly this pattern (Pub/Sub → transform/enrich/aggregate → BigQuery), autoscales for high throughput, handles windowing/late data natively, and has built-in Pub/Sub-to-BigQuery streaming templates. A (Composer) is an orchestrator, not a stream processor. C (Dataproc/Spark) adds cluster management overhead and isn't the native/recommended fit on GCP. D (Cloud Run functions) doesn't scale well for continuous high-throughput streaming with stateful processing like aggregation. https://cloud.google.com/dataflow/docs/guides/streaming-pipeline

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Practice All ADP Questions

Access 65 questions with complete answers and detailed explanations.

View Full ADP Practice Test →

← Back to ADP Study Guide