Introduce WeightedRandomDistributionSelector
(xDS-endpoint pt 1)
#5501
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation:
EdfLoadBalancer
is a basic load balancer which distributes entries based on weight using Earliest Deadline First Scheduling.ref: https://github.com/envoyproxy/envoy/blob/b7818b0df716af47ec22982c5a1cbbace5f2ae15/source/common/upstream/load_balancer_impl.h#L508
This is used not only for request load balancing, but also load balancing based on
Locality
ref: https://github.com/envoyproxy/envoy/blob/b7818b0df716af47ec22982c5a1cbbace5f2ae15/source/common/upstream/upstream_impl.cc#L625
Within our codebase, it seems like we could use
WeightedRandomDistributionEndpointSelector
easily for this purpose. I propose that we extract aWeightedRandomDistributionSelector
and make it publicly available.See the following for a sample use-case in #5450
ref:
armeria/xds/src/main/java/com/linecorp/armeria/xds/client/endpoint/HostSet.java
Lines 38 to 39 in bd4968f
POC: #5450
Modifications:
WeightedRandomDistributionSelector
and move it to theinternal
package.Result:
WeightedRandomDistributionSelector
is now ready to be reused.