-
Notifications
You must be signed in to change notification settings - Fork 13
fix: do not linger unless writing to disk #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zmstone
merged 1 commit into
kafka4beam:main
from
zmstone:251103-do-not-linger-when-replayq-in-memory-mode
Nov 3, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zmstone thanks for implementing this, I think it will help us to get faster PUBACKs when using the EMQX Cloud Kafka integration with hybrid buffer mode and max_linger_ms set to a non-0 value.
I see that
is_writing_to_diskwill return true when the tail segments are written to disk in offload mode. I am afraid that this will cause PUBACK latency to increase due to linger before append when Kafka is unavailable. Would it be possible to also skip linger before append when replayq offloads to disk? I think should not be necessary to linger when offload mode writes to disk:appendshould still write to memory, but tail elements are written to disk, which should allow batching disk writes.An additional question: we need our messages to Kafka to be batched to avoid increasing load on our Kafka cluster. Will all messages that are queued during a timeframe of
max_linger_msstill be batched into a single message at the popping end of the queue, or does this change cause the producer to send messages to Kafka more frequently? The desired behavior for us is that in hybrid mode the producer still lingers, but after enqueueing the messages, decoupling PUBACK latency from kafka message batching.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kiliangrashoff
For EMQX, PUBACK latency increase to cause back-pressure towards MQTT client, otherwise the memory part will eventually overflow.
For Kafka load:
There are other ways to throttle requests towards Kafka.
The most effective is to lower the send-ahead counter.
EMQX has this config named "Max Inflight" from the UI and
max_inflightin config file.The default value is 10, if you lower to 1, there is only going to be 1 request sent to Kafka before Kafka acknowledges. Hence the pending ones will effectively linger (and form a larger batch).
The unconditional linger will add unnecessary latency even when Kafka and Kafka clients are both idling.
It's like the 40m delay of TCP stack without NO_DELAY flag.