Late data

Also known as: late-arriving data

On this page 7

Late data, also called late-arriving data, is any event in a stream that reaches the processing system after the system has declared the relevant period of event time complete, usually because the watermark has already passed the event’s timestamp. In streaming data systems, late data is the unavoidable consequence of the gap between when an event happens and when it is processed.

Handling late data is a trade-off between latency, completeness and cost. A pipeline can wait longer for stragglers, update results after the fact, or discard them, and each choice changes how accurate and how fresh its outputs are.

Why events arrive late

Events arrive late because the path from source to processor has variable and sometimes unbounded delay. Every event carries an event time, the moment it occurred, but the engine observes it at processing time, which can be seconds, hours or even days later.

Typical causes include mobile devices that buffer events while offline, network retries, partitions in a message broker that lag behind others, upstream batch exports, and backpressure that slows one consumer. Clock skew on producing devices can also make events appear late or early even when they were delivered promptly. The table lists common sources with their usual delay ranges.

SourceTypical delayMechanism
Offline mobile clientsMinutes to daysEvents buffered until connectivity returns
Lagging broker partitionsSeconds to minutesUneven consumer throughput
Retries and redeliverySeconds to minutesFailed sends repeated by producers
Upstream batch loadsHoursData exported on a schedule
Clock skewMilliseconds to hoursIncorrect device timestamps
Common sources of late data

How watermarks define lateness

Lateness is defined relative to the watermark, a moving assertion that no more events with an event time earlier than a given timestamp are expected. An event whose timestamp is below the current watermark is late by definition, regardless of how long it actually traveled.

Watermarks are heuristic estimates in most real systems. A common strategy is a bounded out-of-orderness watermark, which trails the maximum observed event time by a fixed delay such as 10 seconds. A tight bound gives fast results but produces more late events; a loose bound reduces lateness but delays every result by the same margin. A perfect watermark is possible only when the source can guarantee ordering, which is rare.

Late data should not be confused with out-of-order data. Out-of-order events arrive in a different sequence from their timestamps but still before the watermark, so the engine places them in the correct window without special treatment. Only events that fall behind the watermark need a late data policy, so the watermark strategy directly determines how many events that policy must handle and how often results are revised.

Strategies for handling late data

Stream processors offer a small set of policies for late events, configured per window or per operator. Apache Flink exposes allowed lateness and side outputs, Apache Beam combines triggers with accumulation modes, and Spark Structured Streaming uses watermark-based state cleanup. The table compares the main policies.

PolicyWhat happens to the late eventEffect on resultsMain cost
DropDiscarded and optionally countedResults final at watermarkLost accuracy
Allowed latenessMerged into the still-open windowWindow result re-emittedLonger-lived state
Side outputRouted to a separate streamMain results unchangedSeparate reconciliation
Retraction or upsertOld result replaced or retractedDownstream sees correctionsSinks must support updates
Batch correctionReprocessed in a later batch jobEventually exact resultsDuplicate pipelines
Late data handling policies

Updates require a sink that can handle them. Appending each revised window to a log creates duplicate rows, while an idempotent upsert into a keyed table or a changelog with retractions keeps downstream consumers consistent. Combining allowed lateness with exactly-once semantics prevents a late event from being counted twice when the pipeline recovers from a failure.

Choosing a lateness budget

The right lateness budget depends on how valuable a correction is compared with the cost of keeping state and waiting. Each window held open for late events keeps its aggregation state in memory or in a state backend, so a budget of days on a high-cardinality key space can require very large state stores.

Measuring the actual lateness distribution of a source is the best starting point: teams typically log the difference between processing time and event time and choose a budget that covers a target share, such as 99.9 percent, of events. The decision table offers common starting points.

Use caseRecommended approachReason
Real-time alertingShort watermark delay, drop or side outputFreshness matters more than completeness
Live dashboardsAllowed lateness with updatesEarly results that become accurate
Billing and financeLong lateness plus batch correctionEvery event must be counted
Machine learning featuresEvent-time windows with side output auditTraining and serving must match
Matching lateness policy to the use case

Common mistakes with late data

The most damaging mistake is windowing on processing time when the business question concerns event time. Results then shift whenever delivery delays change, and late events silently land in the wrong period instead of being identified as late.

  • Dropping late events without metrics, which hides a growing data loss problem.
  • Idle partitions stalling the watermark, so no window closes until an idle-source timeout is configured.
  • Unbounded allowed lateness, which causes state to grow until the job fails.
  • Trusting device clocks blindly, which lets a single bad timestamp advance the watermark far into the future.

The simple explanation

Imagine a teacher collecting homework at 9:00 and grading it at once. A student who hands in work at 9:20 is late: the grades are already out. The teacher can ignore the paper, regrade and announce new results, or put it in a separate pile to handle later.

Late data is the same situation for computers that count events as they happen. Some events always arrive after the count has been closed, and the system needs a clear rule for what to do with them.

How it is used in practice

A ride-hailing company computes trips completed per city every minute for its operations dashboard. Driver phones send trip events, but in tunnels and rural areas some phones lose signal and upload minutes or hours later.

Analysis of a week of traffic shows that 99 percent of events arrive within 15 seconds, while a long tail extends to several hours. The team sets a 15-second watermark delay so the dashboard updates quickly, adds two hours of allowed lateness with upserts into a keyed table, and sends anything later to a side output that a nightly batch job reconciles.

The dashboard stays fresh within about 20 seconds, while the daily driver payment report, built from the reconciled data, matches the trip records exactly.