fix: apply max_linger_ms to memory-mode queues (linger before pop) - #119
Merged
zmstone merged 2 commits intoJul 23, 2026
Merged
Conversation
Since 4.1.1, the linger delay was applied only before enqueue, and only when replayq is writing to disk (to batch disk writes). Memory-mode producers therefore sent each arrival immediately, resulting in many small produce requests under steady low-to-moderate load. Now, when it is time to form a new produce request and the queue holds less than min(max_linger_bytes, max_batch_bytes) bytes, the producer waits up to max_linger_ms for more calls to accumulate before popping the queue. The wait ends as soon as a full batch worth of bytes is queued, so under sustained load full batches are sent with no added latency; only under-sized (tail) batches are delayed, bounded by max_linger_ms. The default max_linger_ms = 0 keeps the previous behavior.
qzhuyan
approved these changes
Jul 23, 2026
thalesmg
approved these changes
Jul 23, 2026
Contributor
Author
|
close + reopen to trigger ci |
This was referenced Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Since 4.1.1, the linger delay (
max_linger_ms) was applied only before enqueue, and only when replayq is writing to disk (an IOPS optimization to batch disk writes). Memory-mode (and not-yet-offloaded) producers therefore sent each arrival immediately, resulting in many small produce requests under steady low-to-moderate load.This PR adds the complementary linger on the pop side of the queue: when it is time to form a new produce request and the queue holds less than
min(max_linger_bytes, max_batch_bytes)bytes, the producer waits up tomax_linger_msfor more calls to accumulate before popping. This pairs withmax_linger_bytesthe same way Kafka's ownlinger.mspairs withbatch.size— no new config key.Behavior
max_linger_ms.max_linger_ms = 0: behavior identical to 4.1.10.maps:get/3defaults, so the new code can be hot-loaded into a running producer with the old state.