Repository navigation
fix(server): raise the RLIMIT_NOFILE soft limit at start-up - #248
Closed
llying-001 wants to merge 1 commit into
Closed
llying-001 wants to merge 1 commit into
llying-001 wants to merge 1 commit into
Conversation
Every proxied PD request holds a client, a prefill and a decode connection, so a container's default soft limit of 1024 open files runs out at a few hundred concurrent requests: accept() fails with EMFILE and the router answers 502. Lift the soft limit to the hard limit (1M when the hard limit is unlimited) before the backend is chosen, so the Rust router inherits it across exec. Tests: tests/unit/server/test_nofile_limit.py (raised to the hard limit, unlimited hard limit, already at the limit, setrlimit failure). Signed-off-by: liyingli <liyingli@amd.com> Co-authored-by: Cursor <cursoragent@cursor.com>
6 of 7 tasks
llying-001
added a commit
that referenced
this pull request
Nov 19, 2026
…y repo at the user's request: AMD-AGI/Infera #246 (U16) #247 (U24) #248 (U14) #249 (U15) #250 (U28) #251 (U7), branches llying/<topic>, conventional titles; fork PRs llying-001/Infera #1-#6 closed and pointed at them Signed-off-by: liyingli <liyingli@amd.com> Co-authored-by: Cursor <cursoragent@cursor.com>
llying-001
marked this pull request as ready for review
November 23, 2026 14:21
llying-001
requested review from
jiejingzhangamd,
limou102 and
xiaobochen-amd
as code owners
November 23, 2026 14:21
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the startup open-file limit adjustment.
No open issues 🎉
What changed in this PR
This PR raises the router’s open-file soft limit at startup to help prevent connection failures under high concurrent PD request load. It applies before backend selection, covering both the Python router and the Rust router launched via exec.
Changes:
- Raises the soft limit to the hard limit, targeting 1,048,576 when the hard limit is unlimited.
- Logs rejected limit changes without aborting startup.
- Adds unit tests for finite and unlimited limits, already-equal limits, and rejected changes.
| File | Description |
|---|---|
tests/unit/server/test_nofile_limit.py |
Tests limit adjustments, no-op behavior, and failure handling. |
infera/server/__main__.py |
Adds the limit-raising helper and calls it before backend selection. |
Review effort: Balanced
9 of 12 tasks
Contributor
Author
|
Folded into #256 (GLM-5.2 vLLM P4D4 example, image and the infera changes it needs); the commit is carried there unchanged. |
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.
Description
Every proxied PD request holds a client, a prefill and a decode connection, so a container's default soft limit of 1024
open files runs out at a few hundred concurrent requests:
accept()fails with EMFILE and the router answers 502. On aGLM-5.2 PD deployment under AgentX traffic the router logged
OSError: [Errno 24] Too many open files2,048 times inthe warm-up, then four requests (one of them a root request) got
502 prefill leg failedand the run aborted. Therouter held 1,150-1,470 descriptors at peak under that load (not a leak). We had been working around it with
docker run --ulimit nofile=1048576.This lifts the soft limit to the hard limit (1M when the hard limit is unlimited) before the backend is chosen, so the
Python router and the Rust router (which inherits it across exec) both get it. The same idea as #239 for
RLIMIT_MEMLOCKin the engine workers.Type of change
Changes
infera/server/__main__.py: raiseRLIMIT_NOFILE's soft limit to the hard limit (capped at 1M when unlimited) atstart-up; a refused
setrlimitis logged and start-up continues.Validation
pytest -m "not slow and not integration", Python 3.10): 3,058 passed (main 3,054), no newfailures. New
tests/unit/server/test_nofile_limit.py: raised to the hard limit, unlimited hard limit, already at thelimit,
setrlimitfailure.pre-commit run --files <changed files>passes.--ulimit nofile=1048576(which raises both limits) since the failure above, so this change hasnot been exercised end to end on its own; it removes the need for that flag.
AI assistance was used to write this change and description.
Checklist: