Search code examples
apache-flink

Flink session window size and its impact on performance


I currently have a session window operator with a trigger time of 2 minutes. I want to know if my understanding of the following is correct.

  • If I were to increase the session time to, per say, 10 minutes, it would only increase memory usage and would not affect CPU.
  • If I were to decrease the session time to 1 minute, it would increase CPU due to potentially more windows being triggered but memory usage would be lower as windows are flushed more frequently.

Is this understanding correct?

Edit. for context, the window is being aggregated


Solution

  • Memory usage depends on whether you are incrementally applying a reduce or aggregate function, or accumulating the window's contents for bulk processing with a ProcessWindowFunction when the window is triggered. E.g., if you are counting events per session with a reduce function, then the state required is just one integer, regardless of session length.

    As for CPU, you may want to consider not just the total CPU effort expended over time, but also the CPU required to compute the results each time a window is triggered. If the windows contain a lot of events, and you are not incrementally aggregating them, there could be some noticeable latency each time a window closes.