Repository navigation
server: idle connections give their slots up under pressure, one address holds a quarter at most - #3048
Conversation
|
Review: not ready. In-flight requests are safe (shedding only runs while a connection is waiting for its next request, so SSE streams and slow readers are never cut), but two parts throttle legitimate deployments.
|
|
Review fixes pushed (369ab42):
Results:
Lean: 345 before and after.
|
…ess holds a quarter at most 128 connections that sent nothing, or one /health each, held every slot for up to 15 minutes. From three quarters full, a connection with no request in progress closes after 5 seconds, and one remote address holds at most a quarter of the slots. Local clients share an address and are not counted by it.
…or it and trusted proxies One address's share of the connection slots (a quarter by default) now applies only once 96 of 128 are open; below that its connections are counted but never refused. --max-connections N (1-1024, default 128), --max-connections-per-address N (0 turns the share off) and --trusted-proxy ADDRESS (repeatable; exact addresses never counted, as loopback is not) set the rule. A connection with no request in progress gives its slot up only with every slot taken, so a pooled client below the limit keeps its connection. IPv6 peers are counted by their /64.
369ab42 to
38ab46c
Compare
What this changes
Before: 128 connections that sent nothing, or one
GET /healtheach, held every connection slot for up to 15 minutes, with or without keys. After: from three quarters full, a connection with no request in progress closes after 5 seconds, and one remote address holds at most a quarter of the slots.SECURITY.mdasks for private reports, so there is no public issue.atc overlap --json: not run.Checks on this head
f7b697ec9f499a6cdd9aa2a2e64d09bab96b22b6python3 tools/zig/lean_check.py, on the base and on this head: 345 on the base, 345 on this head, 0 new.zig fmt --checkon 4 files: passesgit diff --check: passeszig build test-http-limits-host test-server-cpu: 8/8 steps succeeded; 1358/1365 tests passed (7 skipped)zig build check-native-cuda-host compile-flashnext-mtp-parity-host compile-glm-native-open: 11/11 steps succeededzig build test-golden test-server-security test-pull-security: 76/76 steps succeeded; 27/27 tests passedsecurity: one remote address holds at most its share of the connection slotssecurity: local clients share one address and are never limited by itsecurity: connections with no request give their slots up from three quarters fullzig build testand every step that runs on a GPU were not run: this Mac's GPU was serving a model, and no CUDA, ROCm or Intel hardware was available.Receipt
n/a. This change cannot reach inference: it is the HTTP accept path, before any request is read.
Checklist
zig build test-server-security: exit 1.FAIL connections with no request give their slots up under pressure: no slot came free within 12 seconds.Notes for the reviewer
http_admission.zig, with no flag.server.zigis 597 lines with this change; the new logic sits inhttp_admission.zig.Suggested changelog line
Server: under pressure a connection with no request in progress gives its slot up after 5 seconds, and one remote address holds at most a quarter of the connection slots.