-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
xds: implement least_request load balancing policy #8739
Conversation
Implements least_request as defined by [A48](https://github.com/grpc/proposal/blob/master/A48-xds-least-request-lb-policy.md)
Forgot to make this package private from the start
These tests are mostly just a copy of RoundRobinLoadBalancerTest. The main difference is currently in the pickerLeastRequest test case. All other tests should be the same.
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.
Looks great.
xds/src/main/java/io/grpc/xds/LeastRequestLoadBalancerProvider.java
Outdated
Show resolved
Hide resolved
xds/src/main/java/io/grpc/xds/LeastRequestLoadBalancerProvider.java
Outdated
Show resolved
Hide resolved
public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) { | ||
LeastRequestConfig config = | ||
(LeastRequestConfig) resolvedAddresses.getLoadBalancingPolicyConfig(); | ||
// Config may be null if least_request is used outside xDS |
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.
Is that so? I guess it may be if it becomes the default LB? We may want to fix that in gRPC.
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.
When trying this LB implementation together with a custom dns-based resolver it ended up being null here.
I haven't dug into exactly why this is the case however the custom resolver never sets any service config in the resolution result and also loadBalancingPolicyConfig
is marked with @Nullable
here which also is a reason to do a null check.
…actory Needed since InternalLimitedInfoFactory was removed in: grpc#8768
This keeps behavior completely consistent with now when least request is disabled. That is, fail clients with an error that LEAST_REQUEST isn't supported. Also introduce a system property to enable. This allows enablement through Java code.
@ejona86 This is ready for another pass when you have time. |
xds/src/main/java/io/grpc/xds/LeastRequestLoadBalancerProvider.java
Outdated
Show resolved
Hide resolved
This change contains a few various fixes: * Fixes bug in ReadyPicker equality implementation that prevented runtime updates to choiceCount in some cases * Adds additional test and testing logic to ensure the ReadyPicker is created with the correct args * Replaces FakeRandom with a normal mock instead * Move the inFlights increment into the streamCreated hook instead
Could someone help with triggering kokoro and merge (unless there aren't any other reviewers) |
Thanks, @erikjoh! That was more involved than I had hoped. Thank you for the prompt iterations. @dapengzhang0, there was talk of backporting this to 1.44 to make it easier to try out. It is disabled by default, so seems reasonably safe. You think it makes sense? |
I think it's reasonably safe to backport too. |
Implements least_request_experimental as defined by [A48](https://github.com/grpc/proposal/blob/master/A48-xds-least-request-lb-policy.md) These tests are mostly just a copy of RoundRobinLoadBalancerTest. The main difference is currently in the pickerLeastRequest test case. All other tests should be the same.
Implements least_request_experimental as defined by [A48](https://github.com/grpc/proposal/blob/master/A48-xds-least-request-lb-policy.md) These tests are mostly just a copy of RoundRobinLoadBalancerTest. The main difference is currently in the pickerLeastRequest test case. All other tests should be the same.
Implements least_request as defined by
A48