feat: Weighted Query Laning Strategy#19225
Open
mshahid6 wants to merge 2 commits intoapache:masterfrom
Open
Conversation
added 2 commits
March 27, 2026 16:16
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.
Description
Adds a new WeightedQueryLaningStrategy (strategy: "weighted") that scores queries by how many configured thresholds they breach and assigns them to graduated lanes with different capacity limits.
The existing HiLoQueryLaningStrategy uses a simple binary high/low split — any single threshold breach sends a query to the low lane. This misclassifies queries that are expensive on one dimension but cheap on others (e.g., many segments but cheap per-segment). The weighted strategy provides more nuanced lane assignment: a query breaching 1 threshold gets a different lane than one breaching 4.
Same threshold types as ThresholdBasedQueryPrioritizationStrategy:
Each breach adds 1 to the query's score (this can be changed to make scoring different for each threshold). The query is assigned to the lane with the highest minScore it meets. Score 0 = no lane (runs in default pool). Existing caller-set lanes in query context are preserved.
Example config
{
"laning": {
"strategy": "weighted",
"periodThreshold": "P1M",
"durationThreshold": "P1D",
"segmentCountThreshold": 1000,
"segmentRangeThreshold": "P6M",
"lanes": {
"low": { "minScore": 1, "maxPercent": 30 },
"very-low": { "minScore": 3, "maxPercent": 10 }
}
}
}
A query breaching 2 thresholds (score=2) goes to low (30% capacity cap). A query breaching all 4 (score=4) goes to very-low (10% cap). When a lane is full, excess queries get HTTP 429.
Release note
New query laning strategy weighted that scores queries by how many thresholds they breach (segment count, interval duration, data age, segment range) and assigns them to configurable graduated lanes with different capacity limits, providing more nuanced lane assignment than the existing binary hilo strategy.
Key changed/added classes in this PR
[can add to docs once reviewed]
This PR has: