Skip to content

[Router] Make backend request timeouts configurable via environment variables - #1082

Open
vitush93 wants to merge 2 commits into
vllm-project:mainfrom
vitush93:router-configurable-request-timeouts
Open

vitush93 wants to merge 2 commits into
vllm-project:mainfrom
vitush93:router-configurable-request-timeouts

Conversation

@vitush93

Copy link
Copy Markdown

Description

Backend request timeouts in the router's request service were hard-coded:

  • proxy/streaming requests: no total timeout
  • disaggregated prefill: 300s
  • disaggregated decode: 600s
  • multipart (e.g. audio) requests: 300s

This PR makes them configurable via environment variables, following the existing LOADAWARE_BETA env fallback pattern so values can be adjusted on a running deployment without changing the router's command line:

  • ROUTER_PROXY_TIMEOUT_SECONDS (default: unset / no timeout)
  • ROUTER_PREFILL_TIMEOUT_SECONDS (default: 300)
  • ROUTER_DECODE_TIMEOUT_SECONDS (default: 600)
  • ROUTER_MULTIPART_TIMEOUT_SECONDS (default: 300)

Empty or non-numeric values are ignored with a warning and fall back to the defaults.

Testing

  • Added src/tests/test_request_timeouts.py covering default fallback, env override, float values, and empty/non-numeric env values.
  • cd src && python -m pytest tests/test_request_timeouts.py -v

[Bugfix] / [Router]

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces dynamic resolution of backend request timeouts from environment variables (such as ROUTER_PROXY_TIMEOUT_SECONDS, ROUTER_PREFILL_TIMEOUT_SECONDS, ROUTER_DECODE_TIMEOUT_SECONDS, and ROUTER_MULTIPART_TIMEOUT_SECONDS) with fallbacks to default values, alongside corresponding unit tests. Feedback suggests validating that the parsed timeout values are non-negative and finite to prevent unexpected runtime behavior or exceptions, and adding tests to cover these edge cases.

Comment thread src/tests/test_request_timeouts.py Resolved
vitush93 pushed a commit to vitush93/production-stack that referenced this pull request Sep 10, 2026
Address review feedback on vllm-project#1082: negative or non-finite values
(e.g. -10, nan, inf) now fall back to the default instead of being
passed to aiohttp.ClientTimeout. Add unit tests for these cases.
Vit Habada added 2 commits September 10, 2026 16:18
…ariables

Backend request timeouts (proxy, prefill, decode, multipart) were
hard-coded. Allow overriding them via ROUTER_PROXY_TIMEOUT_SECONDS,
ROUTER_PREFILL_TIMEOUT_SECONDS, ROUTER_DECODE_TIMEOUT_SECONDS and
ROUTER_MULTIPART_TIMEOUT_SECONDS, following the LOADAWARE_BETA env
fallback pattern so values can be adjusted on a running deployment.
Empty or non-numeric values fall back to the previous defaults.

Add unit tests for the timeout resolution helper.

Signed-off-by: Vit Habada <[email protected]>
Address review feedback on vllm-project#1082: negative or non-finite values
(e.g. -10, nan, inf) now fall back to the default instead of being
passed to aiohttp.ClientTimeout. Add unit tests for these cases.

Signed-off-by: Vit Habada <[email protected]>
@Mazyod

Mazyod commented Nov 24, 2026

Copy link
Copy Markdown

Thanks for working on this. We ran into the same unbounded proxy timeout in production and solved it in our fork. Some findings that might help here, whatever shape this PR takes:

  • A total timeout ends healthy long streams. A token stream can legitimately run for hours, so we bound silence rather than total duration: ClientTimeout(total=None, connect=C, sock_connect=C, sock_read=R). sock_read re-arms on every chunk, and aiohttp suspends it while it pauses reading for a slow downstream client, so slow readers never trip it.
  • sock_connect doesn't cover DNS or acquiring a pool connection. connect does, so we set both.
  • sock_read doesn't start until the request body is fully sent. A backend that accepts the connection but stops reading can hang a large upload, such as a multimodal payload, with every ClientTimeout field satisfied. We wrap reaching the response headers in asyncio.timeout(connect + read) and disarm it once the headers arrive.
  • Non-streaming requests are silent until generation finishes, so the read bound also caps their duration. It has to exceed the longest legitimate non-streaming generation, including time queued in the engine.
  • When to retry on another backend: connect failures can move to the next engine. A read timeout before the headers arrive is usually caused by the workload, so a retry tends to hit the same bound again. We return a structured 504 instead, and for a stalled SSE stream we send an error event followed by data: [DONE].

The implementation and operator notes are in our fork's README, section "Backend socket timeouts": https://github.com/Mazyod/production-stack#backend-socket-timeouts. We're happy to help reconcile it with this PR or to contribute it separately, whichever you prefer.

Mazyod pushed a commit to Mazyod/production-stack that referenced this pull request Nov 24, 2026
…ibutions

The user removed the two-PR limit and asked to give upstream every verified
finding, letting upstream decide what is useful. Record the new rule, the
PRs and issues posted on 2026-11-24 (vllm-project#1231-vllm-project#1238, plus comments on vllm-project#1082
and vllm-project#1141), what was deliberately not proposed, and how upstream was
verified given its stale lockfile. Link the pending upstream work from the
README patch index. Docs-only; it does not trigger a release.

Signed-off-by: ci-sim <ci@sim>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EkWp1KKx8oCX8JA3mXdkVJ
Signed-off-by: ci-sim <ci@sim>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants