Streaming stock prices from Pub/Sub into Dataflow require computing a moving average of the past 30 seconds every 5 seconds. How should you configure windows and triggers?
Choose an answer
Tap an option to check your answer.
Correct answer: Use a sliding window with duration 30 seconds and period 5 seconds, and emit results with AfterWatermark.pastEndOfWindow()..
Why this is the answer
The problem requires a moving average over the past 30 seconds, updated every 5 seconds. This is a classic use case for a sliding window. A sliding window of 30 seconds duration and 5 seconds period ensures that the window slides forward by 5 seconds each time, processing the last 30 seconds of data. Emitting results AfterWatermark.pastEndOfWindow() is appropriate for producing a result once the system believes all data for that window has arrived, which is standard for batch-like processing within a stream. Incorrect options: Fixed windows do not provide a moving average; they process disjoint segments of data. The other sliding window option has an incorrect duration (5 seconds instead of 30 seconds) and an inappropriate trigger for this requirement.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed