Processing time

On this page 7

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 domainWho sets itStored in the recordTypical use
Event timeSource device or applicationYes, as a fieldCorrect business aggregations
Ingestion timeBroker or source connector on arrivalUsually, as metadataCompromise when sources lack clocks
Processing timeEach operator at handling timeNoLatency-sensitive, approximate results
Time domains in a streaming pipeline

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.

PropertyProcessing timeEvent time
Result determinismNot deterministicDeterministic for the same input
Output latencyLowest possibleBounded by watermark delay
Handling of late dataLate records fall into the current windowExplicit lateness rules and side outputs
Replay of historyCollapses old data into new windowsReproduces original windows
State requirementsSmall, windows close on scheduleLarger, windows stay open until watermark
Implementation effortMinimalTimestamp extraction and watermark strategy
Comparison of processing time and event time

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.

WorkloadRecommended time domainReason
Operational dashboardsProcessing timeShows current system behavior with minimal delay
Throughput and lag alertsProcessing timeMeasures the pipeline, not the source events
Billing and usage meteringEvent timeCharges must match when usage occurred
Fraud detection on sequencesEvent timeOrder of real actions determines risk
Cache expiry and timeoutsProcessing timeDepends on elapsed local time only
Historical backfillsEvent timeReplays must reproduce original windows
Choosing a time domain by workload

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.

SymptomLikely causeRemedy
Spike after a restartBacklog consumed into one windowUse event time or rate-limit catch-up
Results differ on replayWindows depend on wall-clock arrivalSwitch aggregation to event time
Gaps during broker outageWindows closed with no inputMark empty windows or use event time
Inconsistent values across nodesUnsynchronized clocks between machinesEnforce NTP or PTP synchronization
Hourly totals split oddlyDaylight saving or time zone handlingProcess in UTC and convert at display
Symptoms, causes and remedies

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.