Google Cloud Dataflow is a fully managed service for processing and analyzing large data sets in real time or batch mode. It helps you build data pipelines that can handle streaming or batch data easily.
Click to reveal answer
beginner
What is the difference between stream processing and batch processing in Dataflow?
Stream processing handles data continuously as it arrives, like watching a live video. Batch processing handles data in chunks or groups, like watching a recorded video after it is fully available.
Click to reveal answer
intermediate
What programming model does Dataflow use to build pipelines?
Dataflow uses the Apache Beam programming model, which lets you write your data processing logic once and run it in either batch or streaming mode.
Click to reveal answer
intermediate
How does Dataflow handle windowing in stream processing?
Dataflow groups streaming data into windows based on time or other criteria, so you can process data in manageable chunks even though it arrives continuously.
Click to reveal answer
beginner
Why is Dataflow considered serverless?
Dataflow is serverless because Google manages the infrastructure, scaling, and resource allocation automatically, so you only focus on your data processing logic without managing servers.
Click to reveal answer
Which of the following best describes batch processing in Dataflow?
AProcessing data continuously as it arrives
BProcessing data in fixed-size chunks after collection
CProcessing only real-time data streams
DProcessing data without any delay
✗ Incorrect
Batch processing handles data in fixed-size chunks or groups after the data is collected, unlike stream processing which handles data continuously.
What programming model does Dataflow use to support both batch and streaming pipelines?
AMapReduce
BSpark
CHadoop
DApache Beam
✗ Incorrect
Dataflow uses Apache Beam, which allows writing pipelines that can run in batch or streaming mode.
In stream processing, what is the purpose of windowing?
ATo group data into manageable time-based chunks
BTo delete old data automatically
CTo speed up batch jobs
DTo store data permanently
✗ Incorrect
Windowing groups continuous streaming data into time-based or other logical chunks for easier processing.
Which feature makes Dataflow serverless?
AManual resource allocation
BYou must manage virtual machines
CAutomatic scaling and infrastructure management by Google
DRequires installing software on your servers
✗ Incorrect
Dataflow is serverless because Google automatically manages scaling and infrastructure, so you don't manage servers.
Which type of Dataflow job would you use to process live sensor data continuously?
AStream job
BOffline job
CBatch job
DManual job
✗ Incorrect
Stream jobs process data continuously as it arrives, ideal for live sensor data.
Explain how Google Cloud Dataflow supports both stream and batch processing in a single pipeline.
Think about how one code can work for both live and stored data.
You got /4 concepts.
Describe the benefits of using a serverless service like Dataflow for data processing.
Consider what you don't have to do when using serverless.
You got /4 concepts.
Practice
(1/5)
1. What is the main difference between streaming and batch processing in Google Cloud Dataflow?
easy
A. Batch processing is faster than streaming in all cases.
B. Streaming processes data continuously as it arrives; batch processes fixed sets of data.
C. Streaming only reads data; batch only writes data.
D. Batch processes data continuously; streaming processes fixed sets of data.
Solution
Step 1: Understand streaming processing
Streaming processes data continuously as new data arrives in real time.
Step 2: Understand batch processing
Batch processes data in fixed sets or chunks, not continuously.
Final Answer:
Streaming processes data continuously as it arrives; batch processes fixed sets of data. -> Option B
Quick Check:
Streaming = continuous, Batch = fixed sets [OK]
Hint: Streaming = live data; batch = fixed data sets [OK]
Common Mistakes:
Confusing batch as continuous processing
Thinking streaming only reads data
Assuming batch is always faster
2. Which option correctly sets a Dataflow pipeline to run in streaming mode using the Python SDK?
easy
A. options.view_as(StandardOptions).batch = True
B. options.view_as(StandardOptions).stream = False
C. options.view_as(StandardOptions).mode = 'batch'
D. options.view_as(StandardOptions).streaming = True
Solution
Step 1: Identify the correct property for streaming
In Dataflow Python SDK, streaming mode is enabled by setting streaming = True on StandardOptions.
Step 2: Check other options
Batch is default and does not require setting batch = True; mode property does not exist; stream = False disables streaming.
Final Answer:
options.view_as(StandardOptions).streaming = True -> Option D
Quick Check:
streaming = True enables streaming mode [OK]
Hint: Set streaming=True in StandardOptions for streaming mode [OK]
Common Mistakes:
Using batch=True which is invalid
Setting mode='batch' which is not a valid property
Confusing stream with streaming property
3. Given this Python Dataflow pipeline snippet, what will be the output if run in batch mode on input [1, 2, 3]?
import apache_beam as beam
with beam.Pipeline() as p:
result = (
p | beam.Create([1, 2, 3])
| beam.Map(lambda x: x * 2)
| beam.Map(lambda x: x + 1)
)
result | beam.Map(print)
medium
A. 3, 5, 7
B. 1, 2, 3
C. 2, 4, 6
D. Error due to missing streaming option
Solution
Step 1: Trace the transformations
Input list is [1, 2, 3]. First Map multiplies each by 2: [2, 4, 6]. Second Map adds 1 to each: [3, 5, 7].
Step 2: Confirm batch mode output
Batch mode processes all data at once, so output will be printed as 3, 5, 7.
Final Answer:
3, 5, 7 -> Option A
Quick Check:
Multiply by 2 then add 1 = 3,5,7 [OK]
Hint: Apply transformations stepwise to input list [OK]
Common Mistakes:
Forgetting to multiply before adding
Assuming streaming mode affects output here
Expecting original input as output
4. You wrote a Dataflow streaming pipeline but it fails to process live data. Which fix is most likely correct?
medium
A. Set options.view_as(StandardOptions).streaming = True before running the pipeline.
B. Change the input source to a batch file instead of a streaming source.
C. Remove all Map transforms to simplify the pipeline.
D. Run the pipeline without specifying any options.
Solution
Step 1: Identify streaming mode requirement
Streaming pipelines require setting streaming=True in options to process live data.
Step 2: Evaluate other options
Changing input to batch file disables streaming; removing transforms breaks logic; no options means default batch mode.
Final Answer:
Set options.view_as(StandardOptions).streaming = True before running the pipeline. -> Option A
Quick Check:
Enable streaming option to fix live data processing [OK]
Hint: Enable streaming=True to fix live data issues [OK]
Common Mistakes:
Not enabling streaming mode in options
Switching to batch input source mistakenly
Removing necessary transforms
5. You want to build a Dataflow pipeline that reads live sensor data, filters out values below 50, and writes results to BigQuery. Which approach is best?
hard
A. Use streaming mode with a Cloud Storage file source, apply a Map transform, then write to BigQuery sink.
B. Use batch mode with a Cloud Storage file source, apply a Map transform, then write to BigQuery sink.
C. Use streaming mode with a Pub/Sub source, apply a Filter transform, then write to BigQuery sink.
D. Use batch mode with a Pub/Sub source, apply a Filter transform, then write to BigQuery sink.
Solution
Step 1: Choose streaming mode for live sensor data
Live sensor data requires streaming mode to process data as it arrives.
Step 2: Select Pub/Sub as source and apply Filter transform
Pub/Sub is the streaming data source; Filter removes values below 50; BigQuery sink stores results.
Final Answer:
Use streaming mode with a Pub/Sub source, apply a Filter transform, then write to BigQuery sink. -> Option C