Bird
Raised Fist0

Given this Kafka Streams session window configuration:

medium📝 Predict Output Q5 of Q15
Kafka - Streams
Given this Kafka Streams session window configuration:
stream.groupByKey()
  .windowedBy(SessionWindows.with(Duration.ofSeconds(4)))
  .count()

If events arrive at 2000ms, 5000ms, and 9000ms, how many session windows will be created?
A1
B2
C3
D0
Step-by-Step Solution
Solution:
  1. Step 1: Understand session window gap

    Session window inactivity gap is 4 seconds (4000ms).
  2. Step 2: Analyze event gaps

    Gap between 2000ms and 5000ms is 3000ms < 4000ms, so same session.
    Gap between 5000ms and 9000ms is 4000ms, equals gap, so new session starts.
  3. Final Answer:

    2 -> Option B
  4. Quick Check:

    Session windows split when gap ≥ inactivity gap [OK]
Quick Trick: Session windows split if gap ≥ inactivity gap [OK]
Common Mistakes:
MISTAKES
  • Assuming all events belong to one session
  • Misinterpreting inactivity gap as strict greater than
  • Ignoring exact gap equals inactivity gap condition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes