[xds] Implement A114: WRR support for custom backend metrics#12645
[xds] Implement A114: WRR support for custom backend metrics#12645sauravzg wants to merge 3 commits intogrpc:masterfrom
Conversation
186b684 to
418bd90
Compare
Updates the Weighted Round Robin (WRR) load balancing policy to support customizable utilization metrics via the `metric_names_for_computing_utilization` configuration. This allows endpoint weights to be driven by arbitrary named metrics (e.g. `named_metrics.foo`) or other standard metrics (e.g. `memory_utilization`) instead of solely `application_utilization` or the `cpu_utilization` fallback. Refactors metric resolution logic into `io.grpc.xds.internal.MetricReportUtils` to handle the new map lookup and validation requirements.
418bd90 to
d76e770
Compare
|
cc: @danielzhaotongliu To TAL at the PR. |
| if (val != null) { | ||
| return OptionalDouble.of(val); | ||
| } | ||
| } else if (metricName.startsWith("named_metrics.")) { |
There was a problem hiding this comment.
For my education, this should be orthogonal to gRFC A85, but I would like to double check whether the values here should be "in sync" which what is propagated from ORCA load report to LRS. e.g. if lrs_report_endpoint_metrics only allows named_metrics.foo and callinggetMetric(report, "bar") would still be fine.
There was a problem hiding this comment.
That was my initial idea based on Envoy's current implemention. But , this is still in discussion and maybe A114 may be restricted to just supporting named metrics.
https://github.com/grpc/proposal/pull/536/changes#r2831008956
In which case the implementation will be changes appropriately. Keeping this open for now.
xds/src/main/java/io/grpc/xds/WeightedRoundRobinLoadBalancer.java
Outdated
Show resolved
Hide resolved
| if (orcaReportListener != null | ||
| && orcaReportListener.errorUtilizationPenalty == errorUtilizationPenalty) { | ||
| && orcaReportListener.errorUtilizationPenalty == errorUtilizationPenalty | ||
| && Objects.equals(orcaReportListener.metricNamesForComputingUtilization, |
There was a problem hiding this comment.
would the reason using Objects.equals be handling null cases?
There was a problem hiding this comment.
Changed to a simple equals. Yep. I initially decided we should keep it for defensive programming in case someone decides to change make things nullable, but maybe it's moot to worry about it since it's somewhat guaranteed to be non null currently.
xds/src/main/java/io/grpc/xds/WeightedRoundRobinLoadBalancerProvider.java
Outdated
Show resolved
Hide resolved
785c5f9 to
63c5bf3
Compare
Description
This PR implements gRFC A114: WRR Support for Custom Backend Metrics.
It updates the
weighted_round_robinpolicy to allow users to configure which backend metrics drive the load balancing weights.Key Changes
metric_names_for_computing_utilizationfield inWeightedRoundRobinLbConfig.named_metrics.foo) whenapplication_utilizationis absent.MetricReportUtils.application_utilization>custom_metrics(max valid value) >cpu_utilization.