The DSL API’s Stateful Operation: Windowing

Learn how windowing operations work with the Kafka Streams DSL API.

Windowing is a key feature that enables time-based operations on data streams. In Kafka Streams, a window is a fixed-size, logical segment of a stream that contains a subset of records that fall within a specified time range. It allows for operations, such as aggregations and joins, to be performed on records within a specific time window for more fine-grained data analysis.

Types of windowing operations

Let’s get an overview of the different types of windowing schemes in Kafka Streams.

Tumbling windows

Tumbling time windows in Kafka Streams are a type of windowing operation where data is divided into non-overlapping, fixed-size time intervals or windows. All records with timestamps falling within the same window are processed together. Here’s an example of how to use tumbling time windows in Kafka Streams.

Suppose we have a Kafka click-events topic containing records of user clicks on a website, with each record having a timestamp field indicating the time of the click event. We want to count the number of clicks per hour using tumbling windows of one hour each.

Get hands-on with 1400+ tech skills courses.