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

xds: implement least_request load balancing policy #8739

Merged
merged 17 commits into from
Jan 19, 2022

Conversation

erikjoh
Copy link
Contributor

@erikjoh erikjoh commented Dec 3, 2021

Implements least_request as defined by
A48

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.
@erikjoh erikjoh marked this pull request as ready for review December 6, 2021 09:15
Copy link
Member

@ejona86 ejona86 left a 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/ClientXdsClient.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
Copy link
Member

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.

Copy link
Contributor Author

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.
@erikjoh
Copy link
Contributor Author

erikjoh commented Jan 10, 2022

@ejona86 This is ready for another pass when you have time.

@erikjoh erikjoh requested a review from ejona86 January 11, 2022 22:03
@ejona86 ejona86 added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Jan 13, 2022
@grpc-kokoro grpc-kokoro removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Jan 13, 2022
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
@erikjoh
Copy link
Contributor Author

erikjoh commented Jan 19, 2022

Could someone help with triggering kokoro and merge (unless there aren't any other reviewers)

@dapengzhang0 dapengzhang0 added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Jan 19, 2022
@grpc-kokoro grpc-kokoro removed kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run labels Jan 19, 2022
@ejona86 ejona86 merged commit a35336c into grpc:master Jan 19, 2022
@ejona86
Copy link
Member

ejona86 commented Jan 19, 2022

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?

@erikjoh erikjoh deleted the xds-least-request branch January 19, 2022 18:21
@dapengzhang0
Copy link
Member

I think it's reasonably safe to backport too.

ejona86 pushed a commit to ejona86/grpc-java that referenced this pull request Jan 19, 2022
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.
ejona86 pushed a commit that referenced this pull request Jan 19, 2022
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.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants