Inferensys

Glossary

Watermarking

A mechanism in stream processing that tracks the progress of event time and provides a threshold for tolerating and handling late-arriving data in windowed computations.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
STREAM PROCESSING

What is Watermarking?

A mechanism in stream processing that tracks the progress of event time and provides a threshold for tolerating and handling late-arriving data in windowed computations.

Watermarking is a heuristic threshold in stream processing that declares the point in event time up to which a system believes it has observed all data, allowing windowed operators to emit results. It provides a bounded allowance for late-arriving events caused by network latency, clock skew, or out-of-order ingestion, preventing infinite waiting.

When a watermark passes the end of a tumbling or sliding window, the computation triggers and the window's state is finalized. A watermark is not a guarantee of completeness; it is a trade-off between result latency and completeness. A perfectly configured watermark minimizes stale results while accepting a small, controlled amount of data loss for excessively late events.

Event Time Progress Tracking

Key Characteristics of Watermarks

Watermarks are the fundamental mechanism in stream processing that balance result completeness with latency. They provide a declarative threshold for how long a system waits for late data before materializing window results.

01

Event Time vs. Processing Time

Watermarks bridge the critical gap between event time (when data actually occurred) and processing time (when the system observes it). In distributed systems, events can arrive out of order due to network delays, partitioning skew, or upstream backpressure. A watermark declares: "I have observed all events up to timestamp T, minus a bounded lateness allowance." This allows windowed aggregations to produce deterministic, repeatable results regardless of when computation executes.

02

Heuristic Generation

Watermarks are typically generated heuristically by the source operators in a streaming topology. Common strategies include:

  • Periodic Watermarks: Emitted at fixed intervals (e.g., every 200ms), advancing the timestamp to the maximum observed event time minus a configured out-of-orderness bound
  • Punctuated Watermarks: Emitted only when specific events are observed, such as a special "end-of-session" marker
  • Idle Source Detection: If a partition stops sending data, the watermark generator must mark that source as idle to prevent it from indefinitely holding back the overall watermark
03

Late Data Handling

When an event arrives with a timestamp older than the current watermark, it is classified as late. Stream processors provide three strategies for handling late data:

  • Dropping: The event is silently discarded
  • Side Outputs: Late events are routed to a separate stream for logging, auditing, or manual reconciliation
  • Allowed Lateness: Windows are kept alive for an additional grace period, allowing late arrivals to update previously emitted results. This trades increased state size for improved accuracy in use cases like billing or financial reconciliation
04

Watermark Propagation

In a multi-operator topology, watermarks must propagate downstream through all transformation stages. The output watermark of an operator is the minimum of all its input watermarks. This conservative approach ensures correctness: a downstream window operator will never prematurely close a window because one upstream partition is lagging. For multi-input operators like joins, the watermark is held back by the slowest stream, making source skew a critical performance consideration.

05

Completeness vs. Latency Tradeoff

The watermark's out-of-orderness bound directly controls the fundamental tension in stream processing:

  • Tight bound (short delay): Lower latency results but higher risk of excluding late data, reducing accuracy
  • Loose bound (long delay): More complete results but increased output latency and larger state requirements This parameter must be tuned based on business requirements. A fraud detection system may prioritize sub-second latency, while a daily inventory reconciliation can tolerate minutes of delay for perfect accuracy.
06

Idempotency and Exactly-Once Semantics

Watermarks enable exactly-once processing by providing a consistent checkpoint boundary. When a failure occurs, the system rewinds state to the last successful checkpoint and replays events. Because watermarks are deterministic—derived purely from event timestamps—recomputation produces identical window results. This guarantee is essential for use cases like financial aggregation, where duplicate counting would be catastrophic. Frameworks like Apache Flink integrate watermarks directly into their distributed snapshot mechanism.

WATERMARKING IN STREAM PROCESSING

Frequently Asked Questions

Clear, technical answers to the most common questions about how watermarks track event time progress and handle late data in unbounded stream processing systems.

A watermark is a mechanism in stream processing that tracks the progress of event time and declares a threshold beyond which no more data with a timestamp earlier than the watermark is expected to arrive. It is a monotonically increasing timestamp injected into the data stream by the processing framework. When a watermark advances past the end of a window, the system knows it can safely materialize and emit the window's result. Watermarks solve the fundamental tension between completeness and latency in unbounded data processing: they allow you to produce timely results while providing a bound on how long you will wait for late data. In Apache Flink, watermarks are generated either periodically based on the maximum observed timestamp minus a bounded delay, or punctuated based on specific event markers in the stream.

EVENT TIME TRACKING COMPARISON

Watermarking vs. Other Time-Progress Mechanisms

A technical comparison of the primary mechanisms used in stream processing to track event time progress and handle late-arriving data in windowed computations.

FeatureWatermarkingPunctuationsIngress Time

Core Mechanism

Heuristic threshold declaring a lower bound on event time completeness

Special data records injected into the stream signaling a specific timestamp milestone

System clock time when the event enters the processing pipeline

Time Domain

Event time

Event time

Processing time

Handles Out-of-Order Data

Late Data Tolerance

Configurable bounded lateness; data after watermark is considered late

Explicit; processing halts until punctuation is received

None; data is processed immediately upon arrival regardless of event timestamp

Triggering Precision

Approximate; watermark is a best-effort estimate of completeness

Exact; triggers fire precisely at the punctuated timestamp

Deterministic; triggers fire immediately upon data arrival

Implementation Complexity

Moderate; requires heuristic tuning for skew and lag

High; requires application-level injection of control records

Low; relies on system clock, no custom logic needed

Determinism

Non-deterministic; watermark computation depends on data arrival order and skew

Deterministic; punctuation placement is explicit and repeatable

Deterministic; based on wall-clock time

Primary Use Case

General-purpose windowed aggregations with tolerance for late data

Batch-like processing semantics in streaming; strict ordering guarantees

Simple time-based operations where event time is irrelevant

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.