router: add weighted priority cluster specifier plugin (POC) - #46636
Draft
kanurag94 wants to merge 1 commit into
Draft
router: add weighted priority cluster specifier plugin (POC)#46636kanurag94 wants to merge 1 commit into
kanurag94 wants to merge 1 commit into
Conversation
Selects a cluster by walking ordered priority groups and making a weighted choice among the clusters of the first group that has a healthy cluster. Weights describe how to split load within a tier, and groups describe the order in which tiers are tried. A group whose clusters all lack healthy hosts is skipped rather than absorbing its share of the traffic, and weights are renormalized over whichever clusters of a group remain healthy, so excluding one cluster redistributes its share proportionally instead of handing it to whichever entry happens to be last. This is a proof of concept opened for design discussion. It carries no tests yet, deliberately, so the shape can be agreed before the surface is fixed. Signed-off-by: Anurag Aggarwal <kanurag94@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Commit Message: router: add weighted priority cluster specifier plugin (POC)
Additional Description:
This is a proof of concept opened for design discussion, and it deliberately carries no tests yet. I would like agreement on the shape before fixing the surface. It follows @wbpcode's suggestion on #46624 that this kind of selection belongs in a cluster specifier rather than in a cluster implementation, since a specifier is much lighter.
The complete API
The whole configuration surface is three fields:
Wired into a route:
How it picks
Walk the groups in order. Take the first group that has at least one cluster which exists and has healthy hosts. Make a weighted choice among only those healthy clusters.
flowchart LR A["Request"] --> B{"Group has a healthy cluster?"} B -->|No| C["Next group"] C --> B B -->|Yes| D["Weighted choice among its healthy clusters"] D --> E["Cluster"]With the configuration above:
primary_a, 30%primary_bprimary_aprimary_bfallbackfallback, and the request fails thereRow two is the point of the extension. Weights are renormalized over whichever clusters of the group are healthy, so
primary_bgoing down hands its 30% toprimary_arather than failing it.Why not the existing mechanisms
weighted_clusterskeeps sending a cluster its configured share even when every host in it is unhealthy, so row two would fail 30% of requests. It also has no notion of tiers, so there is no way to express "try these two, then that one".The aggregate cluster fails over between priorities of a single linearized host set. This chooses between clusters, so each keeps its own health checking, outlier detection, load balancing policy, and circuit breakers, and the weighting is expressed between clusters rather than between endpoints.
Scope
The cluster is chosen once per request, when the route is resolved, so retries stay within the chosen cluster. That is a deliberate boundary. Moving between clusters across retry attempts is what #46624 is for, and the two compose: this plugin chooses which cluster a request starts in, and a retry-aware cluster type handles progression from there.
Open questions
HostSet::degradedHosts()?Risk Level: Low. This is a new opt-in extension, and no existing code path changes.
Testing: none yet, by design. Unit tests covering group fallthrough, weight renormalization, and the all-unhealthy path will follow once the shape is agreed. It compiles:
bazel build //source/extensions/router/cluster_specifiers/weighted_priority/...Docs Changes: protodoc on the new message only. An architecture overview page will follow with the tests.
Release Notes: changelogs/current/new_features/router__weighted-priority-cluster-specifier.rst
Platform Specific Features: N/A
API Considerations: a new extension proto in a new package, marked alpha in the extension metadata. Nothing existing changes.
Generative AI disclosure: this change was developed with assistance from Claude Code. The author has reviewed and understands the code.