Skip to content

Commit

Permalink
doc: add document on WRR configure examples from service config and x…
Browse files Browse the repository at this point in the history
…ds (#11344)
  • Loading branch information
YifeiZhuang committed Jun 27, 2024
1 parent 7a53fa8 commit 9e21459
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions xds/src/main/java/io/grpc/xds/WeightedRoundRobinLoadBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,30 @@
* 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 {
Expand Down

0 comments on commit 9e21459

Please sign in to comment.