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

Reduce size of buffer used to assemble batches #1204

Merged
merged 1 commit into from
Feb 8, 2018

Conversation

merlimat
Copy link
Contributor

@merlimat merlimat commented Feb 8, 2018

Motivation

The current implementation is using 128KB buffers to accumulate batches before sending. (128Kb is the max batch size, so the intention here is to avoid reallocations on that buffer as it grows).

The problem starts with (batching + “many” partitions + slow responses from broker, due to network limit or reloads). At that point, the batches are still being prepared “on-time”, eg: every 1ms. With many partitions, the per-partition rate is comparatively low, so we end cutting a batch per each message and queuing them for sending. But each message now is taking 128Kb direct memory, instead of 10K or 1K..

Modifications

Adjust the initial buffer size to the max batch size previously sent out by this particular producer.

@merlimat merlimat added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Feb 8, 2018
@merlimat merlimat added this to the 1.22.0-incubating milestone Feb 8, 2018
@merlimat merlimat self-assigned this Feb 8, 2018
Copy link
Contributor

@rdhabalia rdhabalia left a comment

Choose a reason for hiding this comment

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

👍

@merlimat merlimat merged commit 3615e25 into apache:master Feb 8, 2018
@merlimat merlimat deleted the reduce-memory-usage-with-batching branch March 14, 2018 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants