Decide when yesterday can change
A dashboard must show dispatches within five minutes.
The interview prompt
A dashboard must show dispatches within five minutes. A small fraction of scanners arrive a day late. Finance wants a reproducible file every morning. Can both consumers use the same events? Sketch the release and correction rules.
Separate the time an answer is useful from when it becomes final
Store the physical dispatch time and receipt time. In the bookstore example, Saturday’s four copies are received on Saturday. Monday’s two copies arrive on Tuesday. As known Monday night, the dashboard contains four observed copies across these events. After Tuesday’s receipt, a corrected event-time report shows four on Saturday and two on Monday. An ingestion-volume report shows the second message on Tuesday.
A streaming window can emit provisional results early, then incorporate allowed late arrivals while state is retained. A watermark estimates event-time progress. A silent partition may be quiet or disconnected. Inspect how the source and engine handle idleness before promising that all contributing sites are covered. Set the online state horizon from observed delay distributions, recovery cost, and the impact of revisions.
For the finance file, keep its business cutoff, input high-water position, transformation version, and issue timestamp. Deliver a separately identifiable correction when required. The same underlying events can therefore power both a revisable dashboard and an immutable release history. A late event after streaming state expires still needs an explicit batch repair or exception policy.
The model behind the answer
A scanner goes offline on Monday and reports its two field guides on Tuesday. An event-time report puts the physical dispatch on Monday. A processing-time report can put the arrival on Tuesday and measure the delay. Both timestamps are useful. Keeping them separate lets operations answer why its dashboard was short by two at Monday close.
A watermark estimates how far event time has progressed. Pick a window and lateness policy that fit the action. The operations dashboard might issue provisional totals and revise Monday after a late arrival. A distributed finance extract might retain the original release and issue a versioned correction. Spell out what happens to an event that arrives after the online state expires.
A replay of Saturday’s dispatch should add zero units. The first arrival of Monday’s late dispatch should add two. Put both examples in the acceptance test. A pipeline can pass a freshness check and still fail either one. Apache Beam on windows, watermarks, and triggers
Release late-data handling in shadow mode
Ask the agent to write a new event-time view alongside the current report. Replay Monday’s two-unit dispatch on Tuesday after the finance file was issued. Have the reviewer compare the outputs by business day and release ID.
Reviewer decision. The corrected view adds two to Monday, the receipt count changes on Tuesday, and the issued file keeps its original contents. In rehearsal, route readers back to the previous view if the new job rewrites the issued file. Retain the late event so recovery can still produce a corrected release.
Further reading. Designing Data-Intensive Applications, 2nd ed., on handling events that arrive after a window has emitted.
One more question
Can the team meet a physical-dispatch freshness guarantee of five minutes when a scanner is offline all day?
Check your reasoning
It can meet a processing target measured from arrival, or expose an unconfirmed status by a deadline. Confirmed physical truth within five minutes requires timely upstream evidence. Measure source delay separately from compute delay so the owner of each bottleneck is visible.
Previous · Crash after the write · Next · One order lookup and a year of shipments · Complete series map