Quick revision
The short answer
suppress(untilWindowCloses) emits a window only when stream time passes the window end plus grace, and stream time advances only when records with newer timestamps arrive on that task, never with the wall clock. At night some partitions receive no records for hours, so their stream time stands still and the final counts wait in the suppression buffer until morning. We fix it with heartbeat records that advance stream time, or with a Processor API punctuator on wall-clock time, and we bound the buffer deliberately instead of leaving it unbounded.
What to remember
In this answer, we saw that suppress(untilWindowCloses) releases a window only when stream time passes its end plus grace, and that stream time moves only with records on that task. Quiet partitions at night freeze stream time and hold results until morning. Heartbeat records keep the model and advance time; a wall-clock punctuator emits on schedule at the cost of determinism; emitStrategy saves memory but follows the same rule. We replaced the unbounded buffer with a bounded strict one, and the emitted counts are final because later records are dropped.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
suppress(untilWindowCloses) emits a window only when stream time passes the window end plus grace, and stream time advances only when records with newer timestamps arrive on that task, never with the wall clock. At night some partitions receive no records for hours, so their stream time stands still and the final counts wait in the suppression buffer until morning. We fix it with heartbeat records that advance stream time, or with a Processor API punctuator on wall-clock time, and we bound the buffer deliberately instead of leaving it unbounded.
Why this question is asked
This is a classic production surprise with Kafka Streams: an alerting pipeline that is punctual all day goes silent at night, then delivers yesterday's results in a burst the next morning. Nothing is broken; it is doing exactly what the time model says. Interviewers ask it because the answer requires understanding stream time, which is the concept behind windows, grace and suppression. In this answer, we will recap stream time, trace one window through suppression by day and by night, look at the fixes, choose a safe buffer configuration, and explain what the emitted results guarantee.
1A Quick Recap of Stream Time
Kafka Streams has no global clock for windowing. Each task keeps its own stream time, the highest record timestamp it has processed so far. Windows close, grace periods end and suppressed results are released when stream time passes certain points, so the passage of time is driven entirely by data. This is what makes results deterministic: replaying the same input gives the same output, regardless of how fast it is replayed.
The flip side is that a task with no input has a stopped clock. Ten minutes or ten hours of wall-clock time without records are the same to it.
2Following One Window by Day
The window is 5 minutes with 1 minute of grace. Take the window from 10:00 to 10:05 for merchant m-7. During the day the partition receives records every second, so stream time follows the wall clock closely. When a record with a timestamp after 10:06 arrives on that task, stream time passes window end plus grace, the window closes, and suppress emits its final count. That is why results arrive about 6 minutes after each window starts.
- Record arrives on the taskIts timestamp may raise stream time
- Update the window countHeld in the suppression buffer
- Stream time > window end + grace?YesEmit the final count, drop the window from the bufferNoKeep waiting for newer records
3 steps in order. Play them, or step through them one at a time.
Only a new record can move stream time forward, so only a new record can release a window.
3Following the Same Window at Night
At 01:00 merchant m-7 processes its last transaction, and the partition it lives on gets nothing else until 07:30. The window 01:00 to 01:05 holds its count in the suppression buffer, but stream time for that task stays at 01:00:xx, because no newer record has arrived. Window end plus grace, 01:06, is never passed. At 07:30 the first morning record arrives, stream time jumps forward, and every window held overnight is released at once.
Notice that it is per task, not per merchant. A busy merchant on the same partition keeps stream time moving for everyone there; a quiet partition holds back every merchant on it. That is why only some merchants are affected.
6 messages in order. Play them, or step through them one at a time.
4Fixing It
The first option keeps the stream-time model and feeds it: a small job sends a heartbeat record to every partition of the input topic, say once a minute, with the current time as its timestamp. The topology filters heartbeats out after they have advanced stream time, for example by giving them a key that no aggregation uses. It is simple and keeps results deterministic, but it touches the input topic and every producer of it must tolerate the extra records.
The second option emits by the wall clock. With the Processor API we keep our own window store and schedule a punctuator of type WALL_CLOCK_TIME that runs every 30 seconds whatever the input does, and emits every window whose end plus grace is older than the current time minus a safety margin.
The punctuator makes results timely at night, but output now depends on processing time, so a replay can produce different results. emitStrategy(EmitStrategy.onWindowClose()) on a windowed aggregation is a lighter alternative to suppress that uses less memory, but it follows the same stream-time rule, so on its own it does not fix the night problem.
5Choosing the Buffer Configuration
BufferConfig.unbounded() means the suppression buffer can grow without any limit. With many merchants, long grace periods and partitions that hold windows for hours, the buffer can grow until the instance runs out of memory. For untilWindowCloses, Streams only accepts a strict buffer, so the deliberate choice is BufferConfig.maxBytes(...).shutDownWhenFull(): the application stops if the buffer fills, rather than silently emitting early or using unbounded memory. emitEarlyWhenFull() is only allowed with untilTimeLimit, because emitting early would break the promise of one final result per window.
6What the Emitted Results Guarantee
Once a window is closed, records that arrive later for it are dropped and counted in the dropped-records metric. That means each count the alerting service receives is final: no correction will follow. The downstream service can act on it directly and does not need logic to replace earlier answers, which is the reason to use untilWindowCloses in the first place.
7Follow-up questions
How would you test this with TopologyTestDriver?
We pipe records with explicit timestamps: one at 01:00:40 for m-7, and assert that the output is empty. Then we pipe a record with timestamp 01:06:01 on the same partition and assert that the count for 01:00 to 01:05 is emitted once. To reproduce the night, we simply do not pipe anything and confirm nothing comes out. For the punctuator version we call driver.advanceWallClockTime(Duration.ofMinutes(7)) and assert the emission happens without any new input.
Why not just reduce the grace period?
It would shorten the daytime delay slightly but cannot help at night, because without new records stream time does not move at all, whatever the grace.
Does stream time ever move backwards?
No. A late record with an older timestamp is processed (or dropped if its window closed) but does not lower stream time.
8Conclusion
In this answer, we saw that suppress(untilWindowCloses) releases a window only when stream time passes its end plus grace, and that stream time moves only with records on that task. Quiet partitions at night freeze stream time and hold results until morning. Heartbeat records keep the model and advance time; a wall-clock punctuator emits on schedule at the cost of determinism; emitStrategy saves memory but follows the same rule. We replaced the unbounded buffer with a bounded strict one, and the emitted counts are final because later records are dropped.
Open with
Suppression with untilWindowCloses emits a window only when stream time passes the window end plus grace, here six minutes after the window start, and stream time advances only when records with newer timestamps arrive on that task.
Then, if they want more
It never follows the wall clock. During the day records arrive constantly, so results come about six minutes after each window starts.
At night some partitions get nothing for hours, so stream time on those tasks stands still and the final counts sit in the suppression buffer until the first record arrives in the morning, then they all come out together. It is per partition, which is why only some merchants are affected.
To fix it, I would either send periodic heartbeat records to every partition so stream time keeps moving, filtering them out after aggregation, or implement the final emission with the Processor API and a wall-clock punctuator that emits windows whose end plus grace is older than now, accepting that output then depends on processing time. emitStrategy with onWindowClose uses less memory than suppress but has the same stream-time rule.
I would also replace the unbounded buffer with maxBytes and shutDownWhenFull, since untilWindowCloses only allows a strict buffer. Late records after close are dropped, so each emitted count is final.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Kafka documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "During the day results arrive about 6 minutes after each window starts, but at night...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-streams-connect/d4d5d1db60/