[Router] Add bounded consistent hashing with an absolute load gap - #33959
chengcuiping wants to merge 10 commits into
Conversation
687a28c to
10a3b95
Compare
|
@slin1237, the planned two-worker HTTP A/B is complete and the PR is now ready for review. Across 3,200 streaming requests, bounded routing changed the frozen 8-sibling placement from 8:0 to 6:2, reduced mean TTFT by about 13%, and improved throughput by 2.10–2.38%, with correctness passing for every request. The experiment did not distinguish The non-IGW aggregate-ring correction and real Router→HTTP regression coverage are included as well. I would appreciate feedback on the policy contract and configuration surface. |
|
@slin1237 @ByronHsu, could you please confirm whether the separate |
|
Hi @slin1237 @ByronHsu, before I do another current-main refresh, could you please give a direction-level decision on whether SMG wants a separate opt-in bounded_consistent_hashing policy? The implementation and A/B validation are complete, and strict consistent_hashing remains unchanged. If the policy direction is acceptable, I’ll refresh the branch and address review feedback. If this policy surface is not desired, please let me know and I’m happy to close the PR while retaining the benchmark findings in #33625. If scope is the concern, I can also split it in the way maintainers prefer. |
Recommended review order:
Fixes #33625
Supersedes #33791
This follow-up continues #33791 with permission from @waizuichougou.
The original implementation commits are preserved with their authorship.
Permission:
#33791 (comment)
Summary
bounded_consistent_hashingas an independent opt-in policy; strictconsistent_hashingis completely unchanged.min_load_gap, measured in activerequests.
X-SMG-Routing-Key, and only whenboth the absolute and relative load thresholds are exceeded.
X-SMG-Target-Workerand implicit keys fromAuthorization,X-Forwarded-For, andCookiestrict.and HTTP workers.
construct a ring.
Why existing policies do not cover this case
This policy addresses a narrower contract than the existing alternatives:
manualwithassignment_mode=min_loadassigns a new routing key to theleast-loaded worker and then stores that assignment in gateway-local mutable
state. Separate gateway replicas cannot independently derive the same
assignment without shared state.
prefix_hashhashes token prefixes and applies a ratio-only load factor. Theregular Model Gateway HTTP path does not supply tokens, and its affinity key
is not
X-SMG-Routing-Key.cache_awaredetects fleet-wide max/min imbalance and switches toshortest-queue routing. It does not preserve deterministic routing-key
placement or ring-order failover.
consistent_hashingremains unchanged for deployments where affinityis a correctness requirement rather than a cache-locality preference.
Threshold rationale and limitations
The two threshold terms intentionally use different references:
preferred_load - min_healthy_load > min_load_gaprequires that moving the request can reduce active load by a meaningful absolute amount.preferred_load > mean_healthy_load * max_load_skewrequires that the preferred worker is an outlier relative to the healthy fleet. Using theminimum as the ratio denominator would be unstable whenever an idle worker has load zero.
The parameter names are kept distinct from cache-aware
balance_abs_threshold/balance_rel_thresholdbecause the compared workers, selection behavior, and policy scope differ. Naming can be adjusted if the Model Gateway maintainers prefer a shared configuration vocabulary.Limitations. The load signal is local to each gateway process, so multiple gateway replicas may make different best-effort spill decisions. A spill also sacrifices worker-local KV locality and may require a cold prefill on the selected worker. This policy is therefore intended for cache-locality optimization only and must not be used when backend-local session state makes affinity a correctness requirement.
Spill condition
Both comparisons are strict.
Two-worker HTTP A/B and default status
The two-worker HTTP A/B comprised 5 repetitions, 20 cells, 400 groups, and
3,200 streaming requests.
counter leakage.
and reduced mean TTFT by about 13%.
56.95%, while prefill compute increased by about 76%.
and latency.
that any of the three settings differs from either of the others; all three
converged to the same 25% spill and 6:2 placement.
that
min_load_gap=2is optimal. The value 2 remains only a conservative,configurable middle default for this opt-in policy.
The GPU A/B ran at SHA
10a3b95f510584174d8b8c661c7974b97d72291a. The subsequent commits75b73b0c5adc8c92b648caf984cd0cb28ab42877and356299712d1bc649efed655dc610838096b80d3acontain onlydocumentation/comment clarification and Black formatting; neither changes
runtime semantics.
Production signal and limitation
hassellof reported successful affinity and a 3/2/1/2 placement during a storm
drill:
#33625 (comment)
That drill did not record any diverts. It therefore did not exercise the
gateway spill branch and is not a complete validation of spillover behavior.
Validation
cargo fmt --all -- --checkcargo check --locked --all-targetsnot a code failure
git diff --checkgit diff --check origin/main...HEADCI States
Latest PR Test (Base): ✅ Run #33489527894
Latest PR Test (Extra): ❌ Run #33489527729
Latest PR Test (AMD ROCm 7.2): ➖ No AMD PR run found for this commit.