doc: add document on WRR configure examples from service config and xds (#11344)

This commit is contained in:
yifeizhuang 2024-06-27 16:55:38 -07:00 committed by GitHub
parent 7a53fa8bc1
commit 9e2145970a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 0 deletions

View File

@ -64,6 +64,30 @@ import java.util.logging.Logger;
* A {@link LoadBalancer} that provides weighted-round-robin load-balancing over the
* {@link EquivalentAddressGroup}s from the {@link NameResolver}. The subchannel weights are
* determined by backend metrics using ORCA.
* To use WRR, users may configure through channel serviceConfig. Example config:
* <pre> {@code
* String wrrConfig = "{\"loadBalancingConfig\":" +
* "[{\"weighted_round_robin\":{\"enableOobLoadReport\":true, " +
* "\"blackoutPeriod\":\"10s\"," +
* "\"oobReportingPeriod\":\"10s\"," +
* "\"weightExpirationPeriod\":\"180s\"," +
* "\"errorUtilizationPenalty\":\"1.0\"," +
* "\"weightUpdatePeriod\":\"1s\"}}]}";
* serviceConfig = (Map<String, ?>) JsonParser.parse(wrrConfig);
* channel = ManagedChannelBuilder.forTarget("test:///lb.test.grpc.io")
* .defaultServiceConfig(serviceConfig)
* .build();
* }
* </pre>
* Users may also configure through xDS control plane via custom lb policy. But that is much more
* complex to set up. Example config:
* <pre>
* localityLbPolicies:
* - customPolicy:
* name: weighted_round_robin
* data: '{ "enableOobLoadReport": true }'
* </pre>
* See related documentation: https://cloud.google.com/service-mesh/legacy/load-balancing-apis/proxyless-configure-advanced-traffic-management#custom-lb-config
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/9885")
final class WeightedRoundRobinLoadBalancer extends RoundRobinLoadBalancer {