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

"LEAST_REQUEST" lb_policy can possibly select the host with most active requests. #14859

Closed
AdiJohn opened this issue Jan 29, 2021 · 5 comments
Closed
Labels
area/docs area/load balancing stale stalebot believes this issue/PR has not been touched recently

Comments

@AdiJohn
Copy link
Contributor

AdiJohn commented Jan 29, 2021

Title: "LEAST_REQUEST" lb_policy can possibly select the host with most active requests.

Description:
With regarding to unweighted least request loadbalacing, the behavior described in Envoy doc:

An O(1) algorithm which selects N random available hosts as specified in the configuration (2 by default) and picks the host which has the fewest active requests. This is also known as P2C (power of two choices). The P2C load balancer has the property that a host with the highest number of active requests in the cluster will never receive new requests.

However, with the current implementation, it can possibly select the host with most active requests, because it is possible that the N randomly selected hosts are the same, or at least contain duplicates (i.e., when the resulted rand_idx are the same across iterations). Is this expected?

@AdiJohn AdiJohn added the triage Issue requires triage label Jan 29, 2021
@mattklein123 mattklein123 added question Questions that are neither investigations, bugs, nor enhancements and removed triage Issue requires triage labels Jan 31, 2021
@mattklein123
Copy link
Member

I think this is by design at least with the current implementation. Feel free to do a doc update. In the future we could consider an option to retry to avoid duplicates but that seems like a different feature request, and I'm not sure it matters in practice. cc @tonya11en

@mattklein123 mattklein123 added area/docs area/load balancing and removed question Questions that are neither investigations, bugs, nor enhancements labels Jan 31, 2021
@tonya11en
Copy link
Member

tonya11en commented Feb 1, 2021

We had a fairly lengthy discussion in a PR submitted to avoid duplicates when going P2C (#11006). Take a look at the discussion for context, but I believe the gist of it is that the selection probability differences from preventing duplicate selections were negligible if you had >5 hosts. We'd also need to keep a copy of the host vector in each worker thread to do the fisher-yates shuffle, so the memory footprint was non-trivial.

@AdiJohn
Copy link
Contributor Author

AdiJohn commented Feb 11, 2021

I see. Thanks for the explanation.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Mar 14, 2021
@github-actions
Copy link

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs area/load balancing stale stalebot believes this issue/PR has not been touched recently
Projects
None yet
Development

No branches or pull requests

3 participants