perf(server): keep web responsive under provider load - #849
Conversation
|
Warning Review limit reachedNext included review available in 20 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Exact-head k6 E2E rerun on 6103806: 64 concurrent delayed inference users completed 128/128 inference checks while 101/101 liveness checks completed; 0/229 HTTP failures, 25.07 inference requests/s, and 6.2 ms liveness p99 against a deliberate 1 s provider delay. This is loopback synthetic-delay gateway evidence, not a production TLS/provider/soak SLO. |
|
Scheduled review-feedback autofix for this PR head.
|
…zing
k6 end-to-end evidence (loadtests/k6_gateway_smoke.js, mock agent pool so
results measure the gateway layer, not provider latency):
- Baseline (HTTP/1.0, default backlog 5): healthz error rate 7.8% at
200 req/s from connection-reset storms; client-side ephemeral-port
exhaustion ('dial: i/o timeout') at burst; chat error rate 3.4% against
the default 60 req/min per-IP budget.
- After: checks 100%, http_req_failed 0% across 19k requests,
healthz p95 34.5ms / chat p95 52ms under combined load. Thresholds in
the k6 script encode this measured baseline as a regression gate.
Changes:
- Handler.protocol_version = 'HTTP/1.1' — responses already set
Content-Length, so connections are reusable instead of paying a TCP
handshake + TIME_WAIT socket per request.
- GatewayHTTPServer.request_queue_size = 128 — accept queue no longer
overflows under probe bursts.
- Framing guard now emits 'Connection: close' on ambiguous-frame
rejections so keep-alive clients can see the termination they always
enforced server-side (test updated to assert both status and close).
- --rate-limit-requests / --rate-limit-window-seconds CLI flags so
operators and load tests can size the per-client budget explicitly.
92dec2b to
4fa3983
Compare
Outcome
Slow provider calls no longer amplify the stdlib server's five-connection backlog or force a new TCP connection for every fixed-length response.
SOMAXCONNaccept backlogmax_concurrent_runsadmission (503 on saturation)/healthzarrival trafficExact k6 evidence
Command:
Base
838b3de1-> tested candidate source97ce7ed7:The liveness threshold is an isolation invariant (
p99 < synthetic provider delay), not a fabricated production SLO. Full details and APA 7 references:docs/benchmarks/2026-08-25-web-concurrency-k6.md.Verification
python -m pytest -q tests/test_web_concurrency.py tests/test_healthz.py tests/test_security_hardening.py tests/test_api_contract.py tests/test_review_gateway.py tests/test_workflow_run_object_authorization.py— 52 passedpython -m pytest -q tests/test_request_framing.py tests/test_web_concurrency.py tests/test_healthz.py tests/test_security_hardening.py— 33 passedgit diff --check origin/main...HEADScope
No provider credentials or production data are used. TLS, real provider quotas, multi-process serving, and sustained soak capacity remain deployment-specific measurements rather than claims in this PR.