-
Notifications
You must be signed in to change notification settings - Fork 707
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
load balancing: add discovered server in a random position of the server list #565
Comments
I agree with this. We should just reshuffle? |
Reshuffle imo, but remove the last connected server first. ;) |
@derekcollison it would be enough to insert at a random location. |
Shuffle, then add last connected at the end imo. Alternatively, shuffle, then insert randomly anywhere except the front of the list. |
We could get elaborate for sure.. ;) End result should be backup servers always shuffled when added to (don't think required for removal) with current connected at the end of the list. |
If randomize is allowed, discovered URLs will be randomly added to the pool of urls instead of always be appended. See nats-io/nats.go#565 Signed-off-by: Ivan Kozlovic <[email protected]>
After adding discovered URLs from the INFO, reshuffle the pool if option allows Resolves #565 Signed-off-by: Ivan Kozlovic <[email protected]>
If randomize is allowed, discovered URLs will be randomly added to the pool of urls instead of always be appended. See nats-io/nats.go#565 Signed-off-by: Ivan Kozlovic <[email protected]>
Feature Request
Saw this through code inspection.
The connect list is shuffled.
New server are added to the end.
This makes server, the client learns about, less likely to be picked during a re-connect.
Use Case:
Any situation where we have 2 server running, then start a third, then kill one of the former server.
Clients are equally distributed between server (a,b)
We start server c.
Because server c gets added to the end of the list it will result in the client having one of these two lists:
a, b, c (current is a)
b, a, c (current is b)
if now we restart either a or b, all clients will connect to the other one, not c.
Proposed Change:
insert the new server at a random location in the list.
Who Benefits From The Change(s)?
This is useful to reduce thundering heard and better load balancing.
Alternative Approaches
The text was updated successfully, but these errors were encountered: