Choose when to answer and how an answer can improve
Balance event-time completeness, provisional output latency, retained-state cost, and correction protocols using measurable assumptions rather than promising immediate final truth.
On this page
The question for today
What you’ll understand
- Separate a fast provisional answer from an event-time completeness claim.
- Calculate a simple retention-versus-correction tradeoff from explicit delay data.
- Design output identities and metrics that make revisions useful to consumers.
An unbounded stream offers no universal signal that every meaningful old event has arrived. A service can answer quickly with incomplete information, wait longer under a progress policy, and revise when retained late data arrives. The right choice depends on the user's decision: a live dashboard and a settlement-style report need different contracts. Make the timing, correction, and resource choices visible instead of hiding them behind the single word real-time.
Define the question and the output's status
The original Dataflow model separates what is computed, where event-time grouping occurs, when results are emitted, and how successive results relate. These are useful design questions rather than a promise that one implementation solves every source's uncertainty. An early processing-time trigger can improve time to first answer while a later event-time result reflects a more mature input set. Label provisional and revised results so consumers know whether to act immediately, wait, or reconcile. A watermark-based on-time result still inherits the source strategy and allowed-late-data policy.
Choose a stable identity such as key plus window bounds and a result version. A replacement consumer updates one result; a delta consumer applies a declared change; an append-only consumer may need explicit retractions. Without that contract, a sequence of increasingly complete sums can look like several independent business totals. Event-time lag, processing latency, and wall-clock freshness describe different things. Record what the user sees at each stage, including whether delayed sources are absent, rather than reporting only the speed of the fastest initial emission.
Use delay evidence without turning a percentile into a guarantee
An observed arrival-delay distribution can inform a lateness tolerance, but it reflects the sampled workload, clock quality, outages, and observation period. A 99th-percentile delay does not imply that a window containing many events has a 99-percent chance of being complete, especially when outages correlate delays. Define whether completeness means event count, value contribution, source coverage, or absence of a particular important event. The same count of missing events can have very different business impact. Treat rare slow-source behavior as part of the failure envelope, not noise to remove from a convenient percentile.
Waiting or retaining longer can recover more late data at the cost of state, revisions, and possibly delayed decisions. Incremental aggregates can reduce payload but still need timers, keys, and correction metadata. Source retention and sink update capability limit what later reconciliation can accomplish. A consumer that cannot retract an earlier action may require a conservative gate before acting rather than a fast provisional number. Measure the actual objective—useful decision time at a stated completeness level—alongside processing cost and correction frequency, so a faster incomplete output is not silently counted as the same product.
Evaluate the whole result lifecycle
Use a trace with ordinary out-of-order arrivals, an idle source, a burst of delayed events, a recovery, and data arriving after retention expires. Compare initial output latency, eventual accepted result, correction count, rejected late value, state footprint, and external effect invariants. Preserve reference data for reconciliation where the contract needs a later authoritative answer. A change that reduces state by discarding more late events should be reported as a changed completeness policy, not solely an optimization. Document the chosen horizon and the evidence that supports it for this workload.
The probability lab tests the independence illustration. Reset, set BOTH p=0.95 and n=20, predict the all-success bar at about 0.3585, then Play or Step. Reset and re-set BOTH p=0.99 and n=20; predict about 0.8179. Edits retain t, and playback tours exact probabilities rather than generating arrival delays. There are no windows, watermarks, correlated outages, or business values. The comparison shows why a high per-event on-time fraction can still leave many multi-event groups incomplete; a real policy needs measured delay and source behavior beyond this toy assumption.
Work it through
Price a longer correction horizon in explicit units
A fictional retained-event design accepts 1,000 events per second at 80 payload bytes each. Extending its correction horizon from ten to thirty seconds raises the observed accepted fraction from 0.97 to 0.995 for a stated dataset. Ignore all overhead and window overlap.
At ten seconds, raw retained payload is 1,000×10×80=800,000 bytes. At thirty seconds it is 2,400,000 bytes, an additional 1,600,000 bytes.
For 100,000 dataset events, the observed accepted count rises from 97,000 to 99,500, or 2,500 additional events under these measured conditions.
The state payload triples, while the accepted fraction improves by 0.025, or 2.5 percentage points. Decide whether that benefit fits the user's correction and latency contract; the dataset does not prove future delays have the same distribution.
A longer horizon has a quantified payload cost and observed completeness benefit. Neither the benefit nor immediate finality is universal.
The living notebook
Explore the model
Interactive lab · probability
Per-event timeliness is not group completeness
For EACH run Reset, set BOTH p and n, predict, then Play or Step. At n=20 compare p=0.95, all-success probability ≈0.3585, with p=0.99, ≈0.8179. Edits retain t; exact bars model independent equal-probability events, not sampled delays, windows, watermarks, correlated outages, or real business completeness.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forState the unit and assumptions behind completeness; a high per-event fraction alone does not guarantee a whole result is complete.
Pause & reason
Check your understanding
Your turn
Try it yourself
An initial sum for one keyed window is 40. A retained late event adds seven, producing revised sum 47. What should a replacement consumer store, and what happens if an append-and-sum consumer treats both messages as independent totals?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Use the stable result identity and distinguish a replacement value from a delta.
Compare with the solution
A replacement consumer stores 47 for that keyed window, superseding 40. Blindly adding the two total messages gives 87, which double-counts the earlier contribution. A delta consumer would instead need the explicitly encoded change of seven, with compatible recovery and version handling.
Keep the idea
Take it with you
- Fast provisional output and a completeness claim are separate product choices.
- Retention and correction semantics trade resources for a stated opportunity to improve results.
- Evaluate initial latency, revisions, expired data, and final useful outcomes together.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.