Processing time is the local wall-clock time of the machine that executes an operation on a record at the moment the record is handled, regardless of when the underlying event actually happened. In streaming data systems, it is one of the two fundamental notions of time, contrasted with event time, which is the timestamp embedded in the record by its source.
Processing time is the simplest and fastest time domain for stream processing because it needs no timestamps, no watermarks and no buffering for late data. The price is nondeterminism: the same input can produce different results depending on network delays, load, restarts and replays, so it suits monitoring and approximate analytics better than correctness-critical computations.
How processing time is assigned in a stream processor
Processing time is assigned by reading the system clock of the operator that currently holds the record. A stream processor such as Apache Flink, Kafka Streams or Spark Structured Streaming does not store this value in the record; each operator simply consults its own clock when it needs a time reference, for example to decide which window a record belongs to or when a timer should fire.
Because every operator reads the clock independently, a single record has many processing times, one per stage it passes through. A record ingested at 10:00:01.200 may be aggregated at 10:00:01.450 and written to a sink at 10:00:02.100. Windows and timers driven by processing time fire on a fixed schedule of the wall clock, so a one-minute window closes exactly when the minute ends on that machine, whether or not all relevant events have arrived.
The following table separates the three timestamps that a record can carry or acquire in a typical pipeline.
| Time domain | Who sets it | Stored in the record | Typical use |
|---|---|---|---|
| Event time | Source device or application | Yes, as a field | Correct business aggregations |
| Ingestion time | Broker or source connector on arrival | Usually, as metadata | Compromise when sources lack clocks |
| Processing time | Each operator at handling time | No | Latency-sensitive, approximate results |
Processing time versus event time
The essential difference is that event time reflects reality and processing time reflects the pipeline. The gap between them, often called processing-time skew or event-time lag, grows whenever records are delayed by mobile connectivity, broker backlogs, backpressure, consumer restarts or batch uploads from edge devices. In healthy pipelines the skew is usually milliseconds to seconds; during incidents or replays it can reach hours or days.
Event-time processing needs watermarks to estimate how complete the input is and policies for late records. Processing-time logic needs neither, which removes latency and state but also removes any guarantee that a window contains the events that belong to it.
| Property | Processing time | Event time |
|---|---|---|
| Result determinism | Not deterministic | Deterministic for the same input |
| Output latency | Lowest possible | Bounded by watermark delay |
| Handling of late data | Late records fall into the current window | Explicit lateness rules and side outputs |
| Replay of history | Collapses old data into new windows | Reproduces original windows |
| State requirements | Small, windows close on schedule | Larger, windows stay open until watermark |
| Implementation effort | Minimal | Timestamp extraction and watermark strategy |
A common misconception is that processing time is merely event time plus a constant delay. In practice the delay is variable and unbounded, and it differs between partitions, so records can also arrive out of order relative to their event timestamps.
Windowing and timers based on processing time
Processing-time windows group records by the moment each operator receives them. Tumbling, sliding and session windows all exist in a processing-time variant, and the window boundaries align with the wall clock of the task manager or stream thread.
- Tumbling windows close every fixed interval, for example each 10 seconds, and emit a result immediately.
- Sliding windows overlap and recompute on each slide, which makes them useful for rolling throughput metrics.
- Processing-time timers trigger callbacks such as flushing a buffer, expiring cached state or emitting a heartbeat after a set interval.
- Session gaps measured in processing time close a session when no record has arrived for the gap duration, even if the source simply stalled.
Processing-time timers are also used inside event-time jobs. A frequent pattern is a processing-time timeout that forces a result when the watermark stops advancing because an idle partition produces no events. This hybrid approach keeps output flowing without giving up event-time semantics for normal traffic.
When processing time is the right choice
Processing time is appropriate when freshness matters more than exactness or when the question being asked is genuinely about the system itself. Metrics such as messages handled per second, consumer throughput or queue drain rate are processing-time quantities by definition, and computing them in event time would answer a different question.
The decision table below maps typical streaming data workloads to the time domain that experienced engineers usually choose.
| Workload | Recommended time domain | Reason |
|---|---|---|
| Operational dashboards | Processing time | Shows current system behavior with minimal delay |
| Throughput and lag alerts | Processing time | Measures the pipeline, not the source events |
| Billing and usage metering | Event time | Charges must match when usage occurred |
| Fraud detection on sequences | Event time | Order of real actions determines risk |
| Cache expiry and timeouts | Processing time | Depends on elapsed local time only |
| Historical backfills | Event time | Replays must reproduce original windows |
Processing time is also a reasonable default for prototypes and low-stakes enrichment jobs where sources do not provide trustworthy timestamps. Once results feed financial reports, service-level agreements or machine learning features, migrating to event time is usually worth the extra complexity.
Pitfalls of relying on processing time
The main risk of processing time is silent inaccuracy: results look plausible but shift whenever the pipeline slows down. Because no error is raised, teams often discover the issue only when two runs over the same data disagree.
| Symptom | Likely cause | Remedy |
|---|---|---|
| Spike after a restart | Backlog consumed into one window | Use event time or rate-limit catch-up |
| Results differ on replay | Windows depend on wall-clock arrival | Switch aggregation to event time |
| Gaps during broker outage | Windows closed with no input | Mark empty windows or use event time |
| Inconsistent values across nodes | Unsynchronized clocks between machines | Enforce NTP or PTP synchronization |
| Hourly totals split oddly | Daylight saving or time zone handling | Process in UTC and convert at display |
Clock synchronization deserves particular attention. Processing time is only as reliable as the host clock, and machines drift by tens of milliseconds without NTP. Containers, virtual machines resumed from suspension and leap-second smearing can all make processing time jump or repeat, which affects timers and window boundaries.
Processing time also interacts with delivery guarantees. Under at-least-once delivery, a redelivered record may land in a different processing-time window than its first attempt, so deduplication keyed on window identifiers fails. Exactly-once semantics in the engine do not make processing-time results reproducible; they only guarantee that each record affects state once in that particular run.
A non-technical view
Imagine a mailroom that sorts letters by the time they reach the desk, not by the date written on the envelope. Sorting is quick because nobody has to read dates or wait for slow mail. However, a letter delayed by a week ends up in this week’s pile.
Processing time works the same way: a data system labels each piece of information with the moment it handles it. It is fast and simple, but it describes the system, not the real world. When accuracy about when things actually happened matters, event time is the better label.
A concrete example
An online retailer streams page-view events through a message broker into a stream processing job that powers two outputs. The first is an operations dashboard showing views per second in one-minute processing-time windows, which lets the on-call engineer see traffic drops within seconds.
One evening the consumer group stalls for 12 minutes during a deployment. When it recovers, it reads the backlog in about 90 seconds, and the dashboard shows a sharp spike of roughly eight times normal traffic. The spike is real for the pipeline but not for customers. The second output, an hourly marketing report built on event time with watermarks, shows a smooth curve because each view is counted in the hour it occurred.
The team keeps processing time for the dashboard and adds a lag panel, while the report stays on event time. Each time domain answers the question it is suited for.