In stream processing, a watermark is a timestamp that signifies that no events with an earlier event time are expected. It is a heuristic, often based on observed processing time and event time skew, that advances monotonically through the stream. This allows stateful operations like windowed aggregation to fire and produce results for a time window once the watermark passes the window's closing boundary, providing a balance between output latency and result completeness.
Glossary
Watermarking

What is Watermarking?
Watermarking is a core mechanism in stream processing systems that tracks the progress of event time, enabling the system to reason about when all data for a given time window has likely arrived and to trigger windowed computations.
Watermarks are crucial for handling out-of-order events in real-world data streams. They enable the system to manage event time processing correctly without waiting indefinitely for late data. Advanced implementations use punctuated watermarks (triggered by specific events) or periodic watermarks (generated at intervals). This mechanism is foundational for achieving correct, low-latency results in frameworks like Apache Flink and Apache Beam, forming a key part of pipeline observability for time-bound computations.
Key Characteristics of Watermarking
Watermarking is a core mechanism in stream processing that tracks the progress of event time, enabling the system to reason about when all data for a given time window has likely arrived. This allows for the deterministic triggering of windowed computations and the handling of out-of-order data.
Event Time vs. Processing Time
Watermarking operates on event time, the timestamp when an event actually occurred, not processing time, when the system processes it. This distinction is critical for accurate analytics on real-world data where events arrive out-of-order. Watermarks track progress in event time, allowing the system to understand when it can safely assume all data for a period (e.g., 1:00 PM to 1:05 PM) has been seen, even if some late events are still trickling in during processing time.
Handling Out-of-Order Data
A primary function of watermarking is to manage late-arriving data. The watermark is a monotonically increasing timestamp that signifies "no events with a timestamp less than X are expected." Data arriving with a timestamp older than the current watermark is considered late. Systems can define a allowed lateness period, where late data can still be incorporated into window results, after which it is typically discarded or sent to a side output for special handling.
Window Triggering Mechanism
Watermarks directly control when time-based windows (e.g., tumbling, sliding, session) are evaluated and their results emitted. A window's computation is triggered only when the watermark advances past the window's end time plus any configured allowed lateness. This provides deterministic output despite the non-deterministic arrival of streaming data. For example, a 5-minute window ending at 1:05 PM will fire when the watermark passes 1:05 PM (or later, if lateness is allowed).
Heuristic and Perfect Watermarks
Watermarks can be generated in two primary ways:
- Heuristic Watermarks: Estimate event time progress based on observed data patterns (e.g., using the maximum timestamp seen minus a fixed delay). This is common but can be incorrect, potentially causing late data to be missed or windows to fire prematurely.
- Perfect Watermarks: Require knowledge of all event timestamps in advance, which is only possible with data sources that provide explicit progress guarantees (e.g., bounded logs). These guarantee no late data.
Source-Generated vs. Operator-Generated
Watermarks originate from data sources (e.g., Apache Kafka, Apache Pulsar) which can emit watermarks based on partition progress. Downstream operators (like window functions) receive these watermarks and propagate a combined watermark, which is the minimum of all input watermarks. This ensures a global view of progress across parallel streams. If one source partition stalls, the global watermark stalls, preventing windows from closing until all parallel inputs have advanced.
Impact on State Management
Watermarks enable efficient state cleanup in stateful stream processors. Once the watermark has passed the end of a window and its allowed lateness period, the system can safely garbage collect the state associated with that window. This prevents unbounded state growth. The state backend (e.g., RocksDB) relies on watermark signals to know which keyed state is no longer needed for future calculations.
Watermarking vs. Related Concepts
A comparison of watermarking with other core mechanisms used to manage time, state, and data flow in stream processing systems.
| Feature / Mechanism | Watermarking | Checkpointing | Exactly-Once Semantics | Backpressure Handling |
|---|---|---|---|---|
Primary Purpose | Tracks progress of event time to reason about completeness of time windows. | Periodically saves pipeline operator state to durable storage for failure recovery. | Guarantees each record is processed precisely once, despite failures. | Manages data flow rate to prevent fast producers from overwhelming slow consumers. |
Time Domain | Event Time | Processing Time | Processing Time (for coordination) | Processing Time |
Triggering Event | Ingestion of data with timestamps; heuristic or periodic generation. | Periodic timer or after processing N records. | Record acknowledgment and transaction coordination. | Downstream consumer buffer capacity or processing speed. |
Data Guarantee | Completeness (all data for a time window has likely arrived). | Fault Tolerance (state can be restored). | Correctness (no duplicate or missing processing). | System Stability (prevents resource exhaustion). |
State Managed | Maximum event time seen per source/partition. | Full snapshot of operator state (e.g., window buffers, counters). | Transaction logs and idempotent write markers. | Buffer queues and in-flight message counts. |
Impact on Latency | Introduces intentional latency (watermark lag) for completeness. | Can increase latency during synchronous snapshot phases. | Adds coordination overhead (e.g., two-phase commit). | Reduces effective throughput to match slowest component, managing latency. |
Key Implementation | Heuristic: | Asynchronous barrier snapshotting (Flink), Chandy-Lamport algorithm. | Idempotent sinks, transactional writes, distributed log offsets (e.g., Kafka transactions). | Credit-based flow control, blocking reads, drop-oldest/drop-newest policies. |
Failure Scenario Mitigated | Late-arriving data (handled via allowed lateness or side outputs). | Worker/process failure (enables stateful recovery). | Duplicate processing after retries (ensures correct output). | Consumer crash or slowdown (prevents memory overflow and cascade failures). |
Frequently Asked Questions
Watermarking is a core mechanism in stream processing for managing event time. These questions address its function, implementation, and role in ensuring data pipeline correctness.
Watermarking is a time-progress mechanism in event-time stream processing that tracks the completeness of data for a given time window, allowing the system to reason about when all events up to a certain timestamp have likely arrived and triggering computations.
In practice, a watermark is a monotonically increasing timestamp inserted into the data stream. It signifies that no events with an event time earlier than the watermark's timestamp are expected. For example, a watermark of 10:05 suggests the system believes all events timestamped before 10:05 have been ingested. This is crucial for windowed aggregations (like tumbling or sliding windows), as it tells the system when to close a window, emit its results, and discard its state. Watermarks are heuristic and handle out-of-order data by allowing a configurable allowed lateness period before finalizing a window's output.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Watermarking is a core mechanism within stream processing systems. Understanding these related concepts is essential for designing robust, low-latency pipelines that can reason about event time.
Event Time vs. Processing Time
A fundamental distinction in stream processing. Event Time is when an event actually occurred, embedded in its payload. Processing Time is when the system ingests and processes the event. Watermarks track progress in event time, enabling correct computations despite out-of-order arrivals and variable processing delays.
- Example: A sensor emits a reading at 10:00:00 (event time) that arrives at the pipeline at 10:00:05 (processing time) due to network latency.
- Impact: Aggregations based on processing time are inaccurate for time-based business logic; event time with watermarks is required.
Windowed Aggregation
The stream processing operation that watermarking enables. It groups events into finite chunks (windows) for computation (e.g., sum, average). Watermarks signal when the system can assume all data for a given event-time window has arrived, triggering the window's computation and emitting its result.
- Tumbling Windows: Fixed-size, non-overlapping windows (e.g., every 5 minutes).
- Sliding Windows: Fixed-size windows that slide by a specified period, creating overlaps.
- Session Windows: Dynamically sized based on periods of activity separated by gaps of inactivity.
Allowed Lateness
A configurable tolerance period that extends beyond the watermark. It allows a window to accept and incorporate late-arriving data that falls within the allowed lateness bound, updating the previously emitted result. This is crucial for handling data that arrives significantly late without indefinitely delaying computation or bloating state.
- Mechanism: When a late element arrives within the allowed lateness, the window is re-triggered, and a corrected output (or a retraction) may be emitted.
- Trade-off: Increases state size and complexity, as windows must remain open longer.
Trigger
The mechanism that determines when to emit the results of a window. While watermarks are the primary trigger for completeness, systems support multiple, flexible triggers.
- Watermark Progress: Fires when the watermark passes the end of the window (default).
- Processing-Time Timers: Fires at a specific wall-clock time, useful for providing early/approximate results.
- Punctuations / Data-Driven: Fires after observing a certain number of elements or a specific data condition.
- Composite Triggers: Combine multiple triggers (e.g., early firing every 1 second, then final firing on watermark).
State Backend
The storage subsystem that manages the persistent state required for watermarks and windowing. It holds buffered events for open windows, partial aggregates, and watermark timers until they are triggered.
- In-Memory/Heap: Fast but volatile; state lost on failure.
- RocksDB: The default for many systems (e.g., Apache Flink). Offers large, disk-backed state that survives failures via checkpointing.
- External Databases: For queryable state or very large state, systems can integrate with external K/V stores.
- Performance Impact: The choice of backend directly affects throughput, latency, and recovery time.
Exactly-Once Semantics
A processing guarantee that each record in a stream affects the final output exactly once, even in the face of machine or process failures. Watermarking and windowing must be integrated with fault-tolerance mechanisms to maintain this guarantee.
- Dependency on Checkpointing: Periodic, consistent snapshots of pipeline state (including watermark progress and window buffers) are saved to durable storage.
- Recovery: On failure, the pipeline resets its source position, restores state from the last checkpoint, and recomputes. Watermarks are restored, ensuring no duplicate or missing window emissions.
- Idempotent Sinks: Often used in conjunction to handle duplicate emissions that can occur during recovery.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us