Inferensys

Glossary

Watermark

A threshold timestamp in stream processing that declares a point after which the system expects no more late-arriving data for a given window, triggering final calculations.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
STREAM PROCESSING

What is a Watermark?

A watermark is a threshold timestamp in stream processing that declares a point after which the system expects no more late-arriving data for a given window, triggering final calculations.

A watermark is a monotonically increasing timestamp injected into a data stream that tracks event-time progress. It declares to the stream processor that all events with a timestamp earlier than the watermark have been observed, allowing the system to close tumbling or sliding windows and emit final results. Without watermarks, a system would wait indefinitely for late data, preventing timely output.

Watermarks are typically generated heuristically, such as by subtracting a bounded lateness threshold from the maximum observed event time. When a watermark passes the end of a window, the window operator triggers computation and discards window state. This mechanism is fundamental to achieving correct, low-latency results in distributed engines like Apache Flink and Google Dataflow, balancing completeness against the need for real-time fraud scoring decisions.

STREAM PROCESSING FUNDAMENTALS

Key Characteristics of Watermarks

Watermarks are the critical mechanism that allows stream processing systems to handle out-of-order data and make deterministic progress. They act as a declaration of stream completeness, enabling the system to finalize window calculations and release results.

01

Temporal Progress Tracking

A watermark is a monotonically increasing timestamp that flows through the stream alongside data records. It declares that all events with a timestamp less than the watermark value have been observed, allowing operators to close windows and emit results. Unlike wall-clock time, watermarks track event time, which is the time embedded within the data itself. This decoupling is essential for handling out-of-order events caused by network delays, clock skew, or distributed system latencies. The watermark advances based on observed event timestamps, often using a heuristic such as the maximum observed timestamp minus a configured allowed lateness bound.

Event Time
Temporal Domain Tracked
Monotonic
Guaranteed Property
03

Watermark Generation Strategies

Watermarks are generated using periodic or punctuated strategies:

  • Periodic Watermarks: A timer fires at fixed intervals, inspecting the current maximum event timestamp and emitting a new watermark. This is the most common approach in systems like Apache Flink.
  • Punctuated Watermarks: Specific events in the stream trigger watermark generation. For example, a special 'end-of-session' marker or a sensor reading indicating a batch is complete.
  • Idle Source Handling: If a source partition becomes idle (no data), it must be marked as idle to prevent it from holding back the watermark for the entire pipeline. Without this, a single idle partition can stall all window outputs indefinitely.
Periodic
Most Common Strategy
Idle Sources
Critical Edge Case
05

Distributed Watermark Propagation

In a distributed stream processor with multiple parallel source tasks, the operator watermark is the minimum of all input watermarks. This ensures correctness: a downstream operator cannot close a window until every upstream shard has confirmed it has processed all relevant data. This watermark alignment is a critical bottleneck. A single slow or straggling source task can stall the entire pipeline's watermark progress. Advanced systems implement watermark skew mitigation techniques, such as ignoring idle sources or applying per-partition watermarks with a configurable alignment timeout.

Minimum
Watermark Aggregation Function
Stragglers
Primary Bottleneck
06

Watermarks vs. Triggers

While often conflated, watermarks and triggers serve distinct roles. A watermark is a declaration of input completeness. A trigger is a mechanism that determines when window results are materialized. Watermarks are the default and most common trigger, but triggers can also be based on:

  • Processing time: Fire every N seconds regardless of data completeness.
  • Element count: Fire after a certain number of records.
  • Composite triggers: Fire on watermark or early, then update on late arrivals. This separation allows systems to provide speculative early results before the watermark arrives, improving perceived latency while still providing a definitive final result.
STREAM PROCESSING FUNDAMENTALS

Frequently Asked Questions

Clear, technically precise answers to the most common questions about watermarks in real-time fraud detection pipelines, designed for platform engineers and payment systems architects.

A watermark is a threshold timestamp that declares a point after which the stream processing system expects no more late-arriving data for a given window, triggering final calculations. It is the mechanism by which a system asserts, "I have observed all events with timestamps less than or equal to X." In the context of real-time fraud scoring pipelines, the watermark is critical because it determines when a sliding window aggregation of transaction velocity can be finalized and emitted to the risk scoring engine. Without a watermark, the system would wait indefinitely for out-of-order events, making it impossible to block a transaction before the authorization flow completes. The watermark is typically generated by the stream processing engine based on the maximum observed event time minus a configured allowed lateness bound.

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.