-
-
Notifications
You must be signed in to change notification settings - Fork 532
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
Randomize brokers to connect to from the connection seed #631
Comments
Another implementation idea would be to shuffle the list of brokers right after reading it and keep the current connectionBuilder.js as is. Suggestion from @matthiasfeist |
I'm of two minds on this. On the one hand, this is probably the behavior you want in 90% of cases, so from that perspective it makes sense for us to handle it internally. On the other hand, there may be situations where you actually want to prefer connecting to a certain broker, which would become impossible to do if we force a random order. If we don't do this in the client, it's still easily implementable in userland code by just shuffling the list before handing it to the client. Of course there's always the option of shuffling the list by default and then introducing a way to disable that later if/when it becomes needed. |
Allows spreading the initial connection load towards the brokers, we shuffle the order of the seed brokers. They are still iterated through in the same way when a connection fails, just not necessarily in the same order they were originally specified. Fixes #631
Out on pre-release |
In order to better spread connection load towards brokers, clients could randomize the one broker selected to initiate the connection from the seed brokers list.
kafkajs/src/cluster/connectionBuilder.js
Line 33 in 0b70749
The randomization mechanism should be aware of the possiblity that the selected broker is not available. A suggestion could be to change the default
index
value atkafkajs/src/cluster/connectionBuilder.js
Lines 26 to 27 in 0b70749
Maybe something like
The text was updated successfully, but these errors were encountered: