Windowing
Summary: A technique in stream-processing for dividing an unbounded stream into finite buckets of time for the purpose of aggregation.
Sources: chapter11
Last updated: 2026-04-18
Types of Windows
- Tumbling Window: Fixed length; every event belongs to exactly one window. Example: 1-minute windows (10:00:00-10:00:59, 10:01:00-10:01:59).
- Hopping Window: Fixed length but allows windows to overlap. Example: a 5-minute window that starts every 1 minute.
- Sliding Window: Contains all events that occur within some interval of each other. Implemented by keeping a buffer of events sorted by time.
- Session Window: Has no fixed duration. Defined by grouping events for the same user that occur closely together in time; a window is closed when the user has been inactive for a certain period.
Time Handling
Windowing is complicated by the difference between event time and processing time.
- Event Time: The time when the event actually occurred (according to the device clock).
- Processing Time: The time when the event arrived at the stream processor.
- Stragglers: Events that arrive late due to network delays or system pauses. Systems must decide whether to ignore them or publish corrections.