-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Improve Client Side Weighted Round Robin lb policy. #37127
Conversation
- Track whether `updateWeightsOnHosts()` changes any host weights and `applyWeightsToAllWorkers()` if necessary. - Use thread local storage to track callbacks to worker-local load balancers and use `runOnAllThreads` to refresh them to apply the new weights. - Update weights on hosts when new hosts are added, so they get reasonable initial weight. - Calculate median weight of even number of valid hosts as an average of two weights closest to the median. Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov <mef@google.com>
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.
Thanks!
Overall LGTM, although it is challenging for me to prove that the threads interactions (main and worker threads) will always be safe. I think that adding more time-based integration tests may assist in validating that they are safe.
test/extensions/load_balancing_policies/client_side_weighted_round_robin/integration_test.cc
Show resolved
Hide resolved
...d_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb.cc
Outdated
Show resolved
Hide resolved
...d_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb.cc
Outdated
Show resolved
Hide resolved
...d_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb.cc
Outdated
Show resolved
Hide resolved
...d_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb.cc
Outdated
Show resolved
Hide resolved
...ad_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb.h
Outdated
Show resolved
Hide resolved
The code change is LGTM overall. Thanks for the update. Only one comment is added. |
Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov <mef@google.com>
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.
Thank you for your comments!
I believe I've addressed all of them, so please take a look when you have a chance.
...d_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb.cc
Outdated
Show resolved
Hide resolved
...d_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb.cc
Outdated
Show resolved
Hide resolved
...d_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb.cc
Outdated
Show resolved
Hide resolved
...ad_balancing_policies/client_side_weighted_round_robin/client_side_weighted_round_robin_lb.h
Outdated
Show resolved
Hide resolved
test/extensions/load_balancing_policies/client_side_weighted_round_robin/integration_test.cc
Show resolved
Hide resolved
Signed-off-by: Misha Efimov <mef@google.com>
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.
LGTM, thanks!
/retest |
Please merge the main and resolve the conflicts. Than we can land this. |
Signed-off-by: Misha Efimov <mef@google.com>
Done, PTAL. |
cc @adisuissa to merge because @adisuissa have proposed more great suggestions. |
I think they were addressed. |
updateWeightsOnHosts()
changes any host weights andapplyWeightsToAllWorkers()
if necessary.runOnAllThreads
to refresh them to apply the new weights.Risk Level: Low
Testing: bazel test //test/extensions/load_balancing_policies/client_side_weighted_round_robin/...
#34777