Skip to content
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

producer: make Flush.Frequency behaviour better #389

Merged
merged 2 commits into from
Mar 24, 2015

Conversation

eapache
Copy link
Contributor

@eapache eapache commented Mar 24, 2015

Previously the timer would tick every Flush.Frequency regardless of if a message
was actually queued. This meant that if no message arrived for Flush.Frequency
then the next message would be sent immediately, which is unexpected if not
exactly wrong.

With this change the timer is only started when the first message arrives, and
is cleared when a flush occurs. This should result in slightly better batching
for low-volume topics at the result of slightly higher latency (although the
delay will still never be more than Flush.Frequency).

@Shopify/kafka

Previously the timer would tick every Flush.Frequency regardless of if a message
was actually queued. This meant that if no message arrived for Flush.Frequency
then the next message would be sent immediately, which is unexpected if not
*exactly* wrong.

With this change the timer is only started when the first message arrives, and
is cleared when a flush occurs. This should result in slightly better batching
for low-volume topics at the result of slightly higher latency (although the
delay will still never be more than Flush.Frequency).
var (
timer <-chan time.Time
buffer []*ProducerMessage
doFlush chan []*ProducerMessage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flushQueue ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flushTriggered?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

triggerFlush! :P

@wvanbergen
Copy link
Contributor

Looks innocent enough to me :)

eapache added a commit that referenced this pull request Mar 24, 2015
producer: make Flush.Frequency behaviour better
@eapache eapache merged commit b170778 into master Mar 24, 2015
@eapache eapache deleted the better-producer-timer branch March 24, 2015 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants