Problem
Batch jobs deliver insights hours late, which is too slow for fraud detection, alerting or live personalization. Events arrive out of order and late, so naive counting gives wrong answers.
Also known as: event-stream-processing, continuous-processing
Continuously compute over unbounded event streams using windows, state and event-time semantics.
Batch jobs deliver insights hours late, which is too slow for fraud detection, alerting or live personalization. Events arrive out of order and late, so naive counting gives wrong answers.
Stream processing treats data as an unbounded sequence and computes results incrementally as events arrive. It replaces periodic full recomputation with always-on operators that keep state per key and emit updates.
Events flow from a partitioned log into operators: filter, map, join, aggregate. Aggregations run over windows: tumbling (fixed, non-overlapping), sliding, or session windows based on inactivity gaps.
orders topic --> keyBy(customer) --> window(5 min, event time)
--> sum(amount) --> sink (table / topic)
watermark = max_event_time - 30s (window closes when watermark passes its end)
Event time is the timestamp inside the record, not arrival time. The watermark is the engine's estimate that no earlier events remain. Events later than allowed lateness go to a side output for repair. Periodic checkpoints snapshot operator state and input offsets, so recovery resumes without loss or duplication inside the engine. End-to-end exactly-once additionally needs transactional or idempotent sinks.
Medium - always-running cluster and state storage
High - tuning, upgrades, state migration
High - time semantics
Skewed keys overload one partition
Watermark too aggressive drops late events
State grows unbounded without TTL