You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Router] NEU-869: add scoped APIs and pool metrics - #9
When backend connection pools are exhausted, Router now exposes waiting requests by workspace, endpoint, backend URL, and inference replica. The shared aiohttp client applies phase-specific transport limits, while the scoped inference APIs preserve Neutree's workspace/endpoint routing boundary.
Configure the shared ClientSession/TCPConnector with per-backend capacity and startup phase timeouts. The Router uses connect, sock_connect, and sock_read settings with no total request deadline.
Maintain router:connection_pool_waiting through native aiohttp TraceConfig queue hooks. Backend gauges include the inference replica label, and existing incoming-request counter dimensions remain unchanged.
Expose Pooling, Classification, transcription, and translation only through their Neutree-scoped paths. Workspace/endpoint values select the backend and routing policy; the handlers share the existing forwarding lifecycle.
Preserve the existing passthrough route and discovery behavior. The Router PR does not add P/D or LoRA support.
Compatibility
New scoped paths are /{workspace}/{endpoint}/pooling, /{workspace}/{endpoint}/classify, /{workspace}/{endpoint}/v1/audio/transcriptions, and /{workspace}/{endpoint}/v1/audio/translations.
Transcription retains the existing language=en default and forwards the merged implementation's known fields. Translation preserves the original multipart body and boundary.
Client settings are startup configuration and require Router restart/reconciliation. Native file configuration/reload and sleep/wake remain outside this change.
GitHub Actions run 43011878495 built neutree/router:v1.3.0-neu869-4 from e891724554d46550e0021d8c8861f9521ce7a633; amd64 and arm64 manifests succeeded.
On the existing 10.255.1.136 environment, the Router Deployment reached 2/2 Ready with the new image. Scoped /v1/models and /v1/chat/completions returned 200, replica-labelled metrics were exposed, and concurrent requests produced pool-wait values that returned to zero.
Through the Cluster API, timeout values were temporarily set to 2/1/10, 10/1/2, and 10/1/10. Real delayed-response, pool-exhaustion, and TCP blackhole faults returned 504 at the configured phase boundaries. The Cluster was restored to 60/10/600, the temporary Pod and NetworkPolicy were deleted, and the existing inference endpoint returned 200.
Deployed Qwen/Qwen3-ASR-1.7B from the official model-card audio samples on a Tesla-T4 without virtualized memory. Scoped transcription returned HTTP 200 with the expected English and Chinese sample text, and scoped translation returned HTTP 200. The temporary ASR resources and API key were deleted, and neu869-router-real was restored to Running.
Checklist
Applicable pre-commit and local checks pass.
Commits include DCO Signed-off-by.
Router image and runtime E2E evidence are available for review.
Levi080513
changed the title
[Router] NEU-869: improve reliability and audio APIs
[Router] NEU-869: add scoped APIs and pool metrics
Nov 9, 2026
Remove the temporary catch-all route and its discovery bypass now that scoped APIs are explicit. Keep request statistics accurate across cancellation and the latency window.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Active moderate and critical findings remain: the legacy transcription route contradicts the scoped contract, global pooling requests fail on Prometheus None labels, and passthrough backends can stall serial stats scraping when /metrics is unavailable.
This pull request adds scoped inference APIs and backend connection-pool observability to Router while centralizing aiohttp client configuration, forwarding metrics, and multipart audio handling.
Changes:
Adds scoped Pooling, Classification, transcription, and translation forwarding routes.
Configures shared aiohttp connection limits, phase-specific timeouts, and pool-wait metrics.
Extends replica-aware backend metrics, request-stat handling, lifecycle initialization, documentation, tests, and CI configuration.
File
Description
src/vllm_router/utils.py
Adds model types, URLs, payloads, and health-check handling for the new APIs.
src/vllm_router/stats/request_stats.py
Expires stale latency samples during statistics collection.
src/vllm_router/stats/log_stats.py
Adds inference replica labels to logged backend metrics.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Two active issues remain: scoped pooling/classification can route input-only payloads incorrectly via a blocking tokenization call, and malformed JSON audio responses can incorrectly convert the backend status to 502.
When the backend declares application/json but returns an empty or malformed body, backend_response.json() raises here and the handler changes the backend's status to 502. This violates the documented behavior that audio responses preserve backend status/content type (and turns, for example, a backend 422 with a malformed JSON error into a 502); return the buffered raw body with the original status/content type, or otherwise preserve the status on parse failure.
The reason will be displayed to describe this comment to others. Learn more.
app.state.aiohttp_timeout uses args.xxx or None, so 0 means "disabled". That matches the CLI help and the README. However, these four fields are compare=False in dynamic_config, so a hot reload silently ignores changes to them. Can we confirm that on the Neutree side, changing these values always triggers a Router restart, rather than only updating the dynamic config file?
The reason will be displayed to describe this comment to others. Learn more.
These settings are intentionally startup-only. Neutree applies them through the Router Deployment arguments, so changing them triggers a Deployment rollout and Router restart. They are excluded from in-process dynamic configuration updates by design.
The reason will be displayed to describe this comment to others. Learn more.
In proxy_multipart_request, the except asyncio.CancelledError branch and the except Exception branch below it are identical: both call monitor.on_request_complete(..., success=False) and re-raise. They can be merged into a single except BaseException to avoid the duplication. Minor, no behavior change.
The reason will be displayed to describe this comment to others. Learn more.
asyncio.CancelledError has distinct semantics from other exceptions in Router. It indicates that the request task was cancelled, typically because the client disconnected or the Router is shutting down, rather than a backend or transport failure. Router intentionally captures it separately to record cancellation-specific cleanup and re-raise the cancellation. Other exceptions represent backend or request failures and must remain distinguishable, so these branches should not be merged into a broad BaseException handler.
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
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.
When backend connection pools are exhausted, Router now exposes waiting requests by workspace, endpoint, backend URL, and inference replica. The shared aiohttp client applies phase-specific transport limits, while the scoped inference APIs preserve Neutree's workspace/endpoint routing boundary.
Refs NEU-869
Changes
ClientSession/TCPConnectorwith per-backend capacity and startup phase timeouts. The Router usesconnect,sock_connect, andsock_readsettings with no total request deadline.router:connection_pool_waitingthrough native aiohttpTraceConfigqueue hooks. Backend gauges include the inference replica label, and existing incoming-request counter dimensions remain unchanged.Compatibility
/{workspace}/{endpoint}/pooling,/{workspace}/{endpoint}/classify,/{workspace}/{endpoint}/v1/audio/transcriptions, and/{workspace}/{endpoint}/v1/audio/translations.language=endefault and forwards the merged implementation's known fields. Translation preserves the original multipart body and boundary.Unit test
PYTHONPATH=src .venv/bin/python -m pytest -q: 98 passed.0.12.0and Black checks passed.DB test
Not applicable; no database changes.
E2E test
neutree/router:v1.3.0-neu869-4frome891724554d46550e0021d8c8861f9521ce7a633; amd64 and arm64 manifests succeeded.10.255.1.136environment, the Router Deployment reached 2/2 Ready with the new image. Scoped/v1/modelsand/v1/chat/completionsreturned 200, replica-labelled metrics were exposed, and concurrent requests produced pool-wait values that returned to zero.2/1/10,10/1/2, and10/1/10. Real delayed-response, pool-exhaustion, and TCP blackhole faults returned 504 at the configured phase boundaries. The Cluster was restored to60/10/600, the temporary Pod and NetworkPolicy were deleted, and the existing inference endpoint returned 200.Qwen/Qwen3-ASR-1.7Bfrom the official model-card audio samples on a Tesla-T4 without virtualized memory. Scoped transcription returned HTTP 200 with the expected English and Chinese sample text, and scoped translation returned HTTP 200. The temporary ASR resources and API key were deleted, andneu869-router-realwas restored to Running.Checklist