load_aware_locality: implement lb policy#45725
Conversation
|
/coverage |
|
Coverage for this Pull Request will be rendered here: https://storage.googleapis.com/envoy-cncf-pr/45725/coverage/index.html For comparison, current coverage on https://storage.googleapis.com/envoy-cncf-postsubmit/main/coverage/index.html The coverage results are (re-)rendered each time the CI |
ac7a860 to
2f0a702
Compare
Resolve the endpoint-picking child policy, validate policy-level knobs (update period, smoothing constant, variance and probe fractions), reject unsupported enable_oob_load_report, and register the LoadAwareLocality factory. Promote the extension from wip to alpha. Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
Add LocalityLbHostData, the per-host LB policy data that receives ORCA load reports via the multi-slot HostLbPolicyData mechanism and stores a lock-free utilization value behind a release/acquire freshness timestamp for the main-thread weight computation. Reports without a positive utilization signal are dropped (matching gRFC A58 / CSWRR) so signal-less hosts age out rather than pinning their locality as fresh-and-idle. Also lands two foundational types used by the config factory: the LoadAwareLocalityStats counter struct and the LoadAwareLocalityLbConfig holder. Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
Add the immutable RoutingWeightsSnapshot (per-priority, per-source locality weights keyed by Locality identity) and the WorkerLocalLbFactory that owns the shared child ThreadAwareLoadBalancer, publishes snapshots to workers through a thread-local slot, and instantiates the worker LB and its per-locality child LBs. Keying weights by Locality identity keeps the main-thread-to-worker mapping stable when localities are added or removed between snapshot ticks. Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
Add WorkerLocalLb, the per-worker data-path load balancer. It derives LoadBalancerBase for live priority, health, and panic selection, chooses a locality within the selected priority/source by capacity-weighted random over the routing snapshot (looked up by Locality identity), and delegates endpoint selection to a per-locality child LB. Per-source child LBs (healthy/degraded/all-hosts) are built per locality and re-synced on membership changes, with topology rebuilds gated on an actual membership delta. Endpoint retry stays with the child LB; a stack-scoped context wrapper suppresses re-running priority and hash policies, and async child selection is rejected to protect that wrapper. Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
Add LoadAwareLocalityLoadBalancer, the main-thread ThreadAwareLoadBalancer. On a periodic timer it reads each host's ORCA utilization and computes per-locality routing weights for the healthy, degraded, and all-host source slices: EWMA-smoothed headroom (host_count * (1 - smoothed_util)), local preference when cross-locality variance is below threshold, and a small remote probe fraction to keep remote signal fresh. The result is published to workers as an immutable snapshot. Attaches LocalityLbHostData to hosts on membership changes and emits the all_overloaded, local_preferred, probe_active, and stale_locality counters. Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
Bring the load_aware_locality architecture doc in line with the implementation, un-orphan it into the load balancing toctree, and add the new-feature changelog entry. The doc covers the five-stage locality weight computation, the child endpoint-picking policy, the emitted stats, and migration notes from zone-aware routing. Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
Add config, unit, and integration tests. config_test covers policy-knob validation and child-policy resolution; the unit test covers the main-thread weight computation (headroom, EWMA stale-carry, local preference, remote probe, all-overloaded host-count fallback) and the worker-local LB (live priority/panic selection, capacity-weighted locality selection, child delegation, and membership churn); the integration test exercises end-to-end ORCA-driven locality routing. Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
…gle-pass locality pick Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
|
/coverage |
|
Coverage for this Pull Request will be rendered here: https://storage.googleapis.com/envoy-cncf-pr/45725/coverage/index.html For comparison, current coverage on https://storage.googleapis.com/envoy-cncf-postsubmit/main/coverage/index.html The coverage results are (re-)rendered each time the CI |
Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
…l_active stat, review cleanups Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
| if (lb_config.has_enable_oob_load_report() && lb_config.enable_oob_load_report().value()) { | ||
| return absl::InvalidArgumentError( | ||
| "load_aware_locality: enable_oob_load_report is not yet supported"); | ||
| } | ||
| if (lb_config.has_oob_reporting_period()) { | ||
| return absl::InvalidArgumentError("load_aware_locality: oob_reporting_period requires " | ||
| "enable_oob_load_report, which is not yet supported"); | ||
| } |
There was a problem hiding this comment.
Can remove rejection if preferred but OOB is not currently wired up and depends on #45953
| Utilization is derived from each host's ORCA report using the same | ||
| extraction as CSWRR (precedence may be flipped by the | ||
| extraction as CSWRR. The runtime flag | ||
| ``envoy.reloadable_features.orca_weight_manager_use_named_metrics_first`` | ||
| runtime feature). By default: | ||
| defaults to ``true``, so the default precedence is: | ||
|
|
||
| 1. ``application_utilization`` -- value in [0, 1], used when reported and | ||
| greater than 0. | ||
| 2. Named metrics via ``metric_names_for_computing_utilization`` -- max of | ||
| present values, used when ``application_utilization`` is not reported. | ||
| 1. Named metrics via ``metric_names_for_computing_utilization`` -- max of | ||
| present values, used when the result is greater than 0. | ||
| 2. ``application_utilization`` -- used when greater than 0. | ||
| 3. ``cpu_utilization`` -- final fallback. |
Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements the envoy.load_balancing_policies.load_aware_locality load balancer policy, which weights localities based on ORCA-derived utilization headroom and supports in-band ORCA reporting across all priority levels. The changes include configuration parsing, main-thread and worker-local load balancing logic, and comprehensive unit, configuration, and integration tests. Feedback on the pull request points out that the integration test target in the BUILD file should list the envoy.load_balancing_policies.round_robin extension in its extension_names attribute, as it is instantiated during the integration test.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| name = "integration_test", | ||
| size = "large", | ||
| srcs = ["integration_test.cc"], | ||
| extension_names = ["envoy.load_balancing_policies.load_aware_locality"], |
There was a problem hiding this comment.
According to the general rules, for integration tests using envoy_extension_cc_test, all production extensions instantiated by the integration configuration must be listed in the extension_names attribute. Since the integration test instantiates the envoy.load_balancing_policies.round_robin extension, it should be added to extension_names.
extension_names = [
"envoy.load_balancing_policies.load_aware_locality",
"envoy.load_balancing_policies.round_robin",
],
References
- For integration tests using envoy_extension_cc_test, list all production extensions that the integration configuration instantiates in the extension_names attribute. Do not add these extra extension names to config or unit tests, only to the integration test target.
Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
Commit Message: load_aware_locality: implement ORCA utilization-based locality picking
Additional Description:
Implements the envoy.load_balancing_policies.load_aware_locality extension added in #44341 which is a locality-picking LB policy that weights localities by backend utilization aggregated from ORCA load reports.
Some notes:
Risk Level: low/medium - opt-in extension that is still work-in-progress
Testing: Added unit and integration tests, also verified in a real environment.
Docs Changes: Un-orphaned docs/root/intro/arch_overview/upstream/load_balancing/load_aware_locality.rst which will now be rendered in site docs
Release Notes: Added
Platform Specific Features: N/A
Fixes #43665
AI disclosure: portions of this PR and it’s tests were developed with LLM but I have reviewed and understand the code