-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[pulsar-java-client] Decouple partition switch frequency with maxPublishDelay in producer configuration #5788
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
Conversation
| * @see #messageRoutingMode(MessageRoutingMode) | ||
| * @see #batchingMaxPublishDelay(long, TimeUnit) | ||
| */ | ||
| ProducerBuilder<T> batchingPartitionSwitchFrequency(int frequency); |
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.
It is better to add both time interval and time unit in the method, by following the convention of other time related settings.
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.
The current frequency is used to compute switch delay in frequency * maxBatchDelayMicros. Do you mean I should make it a standalone variable? Then if users didn't set this variable, or the user is setting a variable less than maxBatchDelay, I need to use maxBatchDelay in round-robin partitioner?
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.
Oh I misread the code. I see it now. Then that's fine to me.
| private MessageRouter customMessageRouter = null; | ||
|
|
||
| private long batchingMaxPublishDelayMicros = TimeUnit.MILLISECONDS.toMicros(1); | ||
| private int batchingPartitionSwitchFrequencyByPublishDelay = 10; |
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.
Add "Micros" to the name so people know the time unit directly by reading the name.
codelipenghui
left a comment
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.
The change looks good me, is it possible implement in RoundRobinPartitionMessageRouterImpl? Looks the batching partition switch frequency only works in RoundRobin mode. Please considering whether this configuration should in ProducerBuilder.
I think we are exposing the capability of changing partition switch frequency to users? If so, the user conf in |
|
@sijie I have discussed with yijie, i'm not sure use a custom router is reasonable here. we can support setting frequency in RoundRobinPartitionMessageRouterImpl and user use it like: Which can reduces |
|
@codelipenghui that works for me. |
|
run java8 tests |
|
run java8 tests. |
Motivation
Currently, while using round-robin message router, messages would be route to different partitions at the
maxPublishDelayboundaries. However, when GC occurs, the output partition would change frequently and results in small batches.This PR introduces a conf field setting the round-robin partition switch frequency:
batchingPartitionSwitchFrequencyByPublishDelay. With this PR, the partition switch interval could be set asmaxPublishDelay*frequency.Modifications
batchingPartitionSwitchFrequencyByPublishDelayinProducerConfiguratiionData.javaVerifying this change
This change is already covered by existing tests.
Does this pull request potentially affect one of the following parts:
Documentation