Windowing brings structure to an unbounded data stream by grouping events into finite sets over which aggregations can be computed. Without windows, a streaming aggregation must either accumulate state forever or produce approximate results. Windows bound the aggregation scope to a defined time interval, enabling exact aggregations that are eventually emitted and forgotten. The three window types — tumbling, sliding, and session — each model a different grouping pattern, and choosing the correct one fundamentally shapes both the memory footprint and the analytical meaning of the output.
Window assignment is always based on event time in well-designed streaming pipelines, not processing time. Event-time windows produce correct results even when events arrive out of order, because each event is assigned to its window based on the timestamp embedded in the event itself. Processing-time windows produce results that depend on when events arrived at the processor — non-reproducible and incorrect whenever there is latency or reordering in the delivery path, which is true of virtually every production streaming pipeline that reads from Kafka.