feat: replace Werkzeug dev server with waitress for high-concurrency adapter#896
Merged
AdamRajfer merged 3 commits intomainfrom Apr 8, 2026
Merged
Conversation
…adapter Werkzeug's `run_simple(threaded=True)` creates an unbounded thread per request with a socket backlog of 5, causing "connection reset by peer" errors at scale (11k+ concurrent connections). Replace with waitress, a production WSGI server that uses a fixed thread pool (default 2048) with proper connection queuing (default 16k connection limit). Also raises the file descriptor limit (RLIMIT_NOFILE) to 65536 in the adapter subprocess to prevent fd exhaustion under high concurrency. Configurable via env vars: - ADAPTER_SERVER_THREADS (default: 2048) - ADAPTER_SERVER_CONNECTION_LIMIT (default: 16384) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Alex Gronskiy <agronskiy@nvidia.com>
Contributor
|
/ok to test 9162ca1 |
AdamRajfer
approved these changes
Apr 8, 2026
Contributor
|
/ok to test 19bb754 |
Signed-off-by: Adam Rajfer <arajfer@nvidia.com>
Contributor
|
/ok to test c8ab793 |
agronskiy
added a commit
that referenced
this pull request
Apr 13, 2026
…ainer errors Fixes two issues introduced in #896: - select.select() breaks with fds > 1023 after raising RLIMIT_NOFILE - localhost may resolve to ::1 in IPv6-disabled containers (EADDRNOTAVAIL) Signed-off-by: Alex Gronskiy <agronskiy@nvidia.com>
1 task
agronskiy
added a commit
that referenced
this pull request
Apr 13, 2026
Fixes two issues from #896: - **`filedescriptor out of range in select()`**: `select.select()` can't handle fds > 1023. After raising RLIMIT_NOFILE to 65536, this is easily hit. `asyncore_use_poll=True` switches to `select.poll()` which has no fd limit. - **`EADDRNOTAVAIL` in containers**: `localhost` resolves to `::1` in IPv6-disabled environments. `ipv6=False` forces IPv4-only binding. Reproduced the select() issue in a core-evals container (`terminal-bench:2026-02-09T10-38-9216d4e3-amd64`): default soft=1024, hard=524288; after raising and opening 1100 sockets, `select.select()` fails exactly as reported. ## Test plan - [x] 21/21 adapter server unit tests pass Signed-off-by: Alex Gronskiy <agronskiy@nvidia.com>
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.
Summary
run_simple(threaded=True)with waitress, a production WSGI server with a fixed thread pool and proper connection queuingRLIMIT_NOFILE) to 65536 in the adapter subprocessADAPTER_SERVER_THREADS(default 2048) andADAPTER_SERVER_CONNECTION_LIMIT(default 16384) for tunabilityContext
At 11k+ concurrent connections the Werkzeug dev server causes "connection reset by peer" errors due to:
Waitress uses a fixed thread pool with channel-based I/O, so excess connections queue rather than getting reset. Single-process architecture is preserved, keeping all
threading.Lock()in interceptors (caching, progress tracking, stats) valid.Test plan
🤖 Generated with Claude Code