Repository navigation
[Serve] Preserve model affinity for multiplexed HAProxy ingress - #66585
Closed
eicherseiji wants to merge 2 commits into
Closed
eicherseiji wants to merge 2 commits into
eicherseiji wants to merge 2 commits into
Conversation
Signed-off-by: Seiji Eicher <[email protected]>
Signed-off-by: Seiji Eicher <[email protected]>
Contributor
Author
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.
Why
@serve.multiplexedworks through direct HTTP and gRPC ingress, but generic HTTP traffic through HAProxy currently selects an ingress replica before that replica readsserve_multiplexed_model_id. The model therefore loads correctly on whichever replica HAProxy picked, but repeated requests do not get Serve's normal warm-model affinity and can cause duplicate loads and eviction churn.What
@serve.multiplexedunder HAProxy.choose_replica(_reserve=False).Host,Content-Length,Connection,Transfer-Encoding, and headers named byConnection; it regenerates the internal request's framing itself.Generic Serve model multiplexing carries its model ID in
serve_multiplexed_model_id, so this change does not buffer, copy, or parse the client request body. The ingress router receives the normal end-to-end headers, including the model ID, while HAProxy continues streaming the original request directly to the selected replica. Request-body forwarding remains controlled independently for body-aware routers.The model header receives one additional normalization step: HAProxy accepts the underscore and hyphen spellings, selects one canonical value for the routing decision, removes conflicting copies, and restores the value returned through the trusted router response. This ensures the router and selected replica cannot observe different model IDs.
Why not route entirely inside HAProxy?
balance hdr(serve_multiplexed_model_id)with consistent hashing would be smaller, but it is not equivalent to Serve's multiplexing policy. It cannot prefer the replicas that actually report a model loaded, place a cold model on a replica with the fewest loaded models, or react correctly to LRU eviction. It can consequently retain stale affinity, overload one replica's model cache, and reshuffle placement during scaling.Publishing loaded-model sets to HAProxy and selecting in Lua could preserve those semantics, but model loads and evictions are dynamic. Doing this without frequent HAProxy configuration reloads would require a new runtime-map/control-plane mechanism. The internal router reuses the existing model-location propagation and routing policy instead.
OpenAI multi-model routing is separate: its model name is in the JSON body, so that path must inspect enough of the body to extract
model. This PR addresses generic@serve.multiplexed, whose routing key is an HTTP header.Scope
This restores cache-aware selection for HTTP ingress. Direct gRPC ingress already propagates multiplexed model IDs correctly, but this HTTP ingress-request-router mechanism does not apply to the gRPC frontend.
Static
@serve.multiplexedusage is detected at application build time. A multiplexed wrapper created dynamically inside a replica constructor cannot be detected before the application is deployed and is not auto-routed by this change.The automatic router is HAProxy-only. With the Python proxy, every request already flows through the ingress deployment's ordinary Serve request router, so deploying the peer ingress-router adapter would be redundant and unused.
Tests
test_multiplexed_e2eunder HAProxy to cover warm-model affinity across two replicas.Duplicate search
Searched open Ray PRs for HAProxy/direct-ingress model multiplexing and ingress-router work. The merged #65678 enables model-ID propagation and the merged #65679 adds multiplex support to
RoundRobinRouter; neither makes generic HAProxy ingress consult Serve's model-aware router. No open duplicate was found.AI assistance
AI assistance was used for implementation and testing. The generated changes require submitter review before this draft is marked ready.