CLOUD CONCEPT

Event-Time Processing

Event-time processing transforms and aggregates data according to when events occurred rather than when a processing system receives or handles them.

Cloud Concepts Hub →

What is Event-Time Processing

Distributed streams often contain delayed, duplicated, or out-of-order records, so arrival order does not reliably represent the order of real-world activity. Event-time processing uses event timestamps, windows, and explicit lateness policies to produce meaningful time-based results, including streaming features for machine learning.

Event-time processing uses the timestamp describing when an event occurred to determine its place in a calculation. This differs from processing time, which is when an application handles the record, and ingestion time, which is when an ingestion system receives it. A sensor reading generated at 10:02 but delivered at 10:08 belongs to the 10:02 event-time interval, even though the processor sees it six minutes later.

This distinction matters when transforming streaming data into machine learning features. Suppose a fraud detection pipeline computes each customer's transaction count and average purchase amount in five-minute windows. Using processing time can place delayed transactions in the wrong interval and make features depend on network delays or consumer backlogs. Event-time windows preserve the intended relationship between transactions and the periods they describe.

A practical pipeline first parses and validates an event timestamp, normalizes its time zone and units, and retains a stable event identifier. It then groups records by an entity key, such as customer ID, and applies tumbling, sliding, or session windows. Transformations can include filtering invalid values, normalizing measurements, enriching records, and calculating counts, sums, or other features. Invalid timestamps and implausibly future-dated events need explicit handling because they can distort windows and progress tracking.

Out-of-order arrival requires the processor to retain state while waiting for additional records. A watermark represents progress through event time and supports decisions about window completion and state cleanup; it is not proof that earlier events can never arrive. Watermark behavior differs among engines. Spark Structured Streaming can use an event-time column with withWatermark and window aggregations, while Apache Flink supports timestamp assignment, watermark strategies, and configurable handling of late events.

For example, a pipeline might calculate five-minute transaction features while tolerating ten minutes of out-of-order data. A transaction from 10:02 arriving at 10:08 can still contribute while the relevant window state remains available. A much later transaction may be discarded, routed for reconciliation where supported, or incorporated through a separate correction workflow. The exact behavior depends on the engine, operator, watermark progress, and output configuration, not simply on elapsed wall-clock time.

Longer lateness tolerance can improve completeness but increases retained state, recovery work, and the delay before results become final. Early results can reduce serving latency, but downstream storage must support updates or versioned outputs if results change. Checkpoints help recover processing state, while stable identifiers and idempotent writes address duplicates and retries. Event-time processing alone does not guarantee exactly-once results or globally sort the stream.

In cloud implementations, managed stream processors or Spark jobs handle stateful event-time aggregations, while functions can validate, enrich, and transform incoming records. A function invocation or batch boundary is not automatically an event-time window. For machine learning, preserve timestamp semantics across training and inference, and distinguish occurrence time from availability time: historical features must not include information that was unavailable when a prediction would have been made. Monitor timestamp quality, watermark progress, late-record rates, state size, and feature freshness to balance correctness with operational cost.

Key aspects of Event-Time Processing

Event-time processing combines meaningful timestamps, stateful windows, progress tracking, and explicit correction policies to produce time-consistent streaming results.

Occurrence-based timestamp semantics

Use the timestamp representing when the underlying activity occurred, rather than substituting ingestion or execution time. Validate timestamp units, time zones, and clock skew before using the field in transformations.

Event-time windows

Assign records to time intervals or sessions using their event timestamps. Keyed window aggregations produce features such as per-device average temperature or per-customer transaction counts.

Watermarks and out-of-order data

Use engine-specific watermark mechanisms to track event-time progress and bound retained state. A watermark supports completeness decisions but does not guarantee that no older records will arrive.

Explicit late-data handling

Define whether late records update existing results, are excluded, or enter a correction workflow. Match that policy to downstream support for upserts, revisions, and historical recomputation.

State, recovery, and duplicate control

Retain window state long enough to support the selected lateness policy and checkpoint it for recovery. Handle duplicates and sink retries separately because event-time semantics do not establish exactly-once delivery.

Time-correct machine learning features

Keep feature window definitions consistent between historical preparation and online computation. Track data availability as well as occurrence time to prevent historical training examples from using information unavailable at prediction time.

Cloud services for Event-Time Processing

Amazon Kinesis Data Streams can ingest records containing source event timestamps, and AWS Lambda can validate or enrich those records before further processing. Amazon Managed Service for Apache Flink provides stateful event-time processing with timestamps and watermarks. AWS Glue streaming ETL or Spark applications on Amazon EMR offer another approach for event-time window aggregations and feature engineering. Across these designs, retain original timestamps and identifiers, configure checkpointing and late-data policies, and choose downstream writes that tolerate retries and revised results. The transport, processing engine, and destination each contribute different guarantees; none should be assumed to provide end-to-end correctness automatically.

Amazon Managed Service for Apache Flink image Amazon Managed Service for Apache Flink

Runs Apache Flink applications that assign event timestamps, generate watermarks, and maintain keyed state for event-time windows. Applications can configure lateness and late-data handling for supported operators.

Open Amazon Managed Service for Apache Flink →
AWS Glue image AWS Glue

AWS Glue streaming ETL jobs use Spark Structured Streaming to transform incoming records. Engineers can implement event-time aggregations and watermarking in Spark code, with checkpointing supporting recovery.

Open AWS Glue →
Amazon EMR image Amazon EMR

Provides environments for running Spark Structured Streaming applications with event-time windows, watermarks, and stateful transformations. Engineers configure the application logic, checkpoint storage, and output behavior.

Open Amazon EMR →
AWS Lambda image AWS Lambda

Can validate event timestamps, normalize fields, enrich records, and perform lightweight streaming transformations. Its stream batching and invocation boundaries do not automatically provide arbitrary payload-based event-time windowing; more complex aggregations require appropriate state management or a stream-processing engine.

Open AWS Lambda →
Amazon Kinesis Data Streams image Amazon Kinesis Data Streams

Transports streaming records to transformation consumers while preserving event timestamps carried in their payloads. Its approximate arrival timestamp represents stream arrival, not necessarily when the underlying event occurred, and the service does not itself perform event-time aggregation.

Open Amazon Kinesis Data Streams →