Skip to content

Park idle server sessions off worker threads - #403

Merged
bneradt merged 1 commit into
yahoo:masterfrom
bneradt:park-idle-server-sessions
Oct 12, 2026
Merged

bneradt merged 1 commit into
yahoo:masterfrom
bneradt:park-idle-server-sessions

Conversation

@bneradt

@bneradt bneradt commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

verifier-server dedicates a worker thread to each accepted connection
for the connection's whole life, including the time it sits idle
between transactions. A proxy keeps pooled origin connections open
between requests, so in prod sim replays through ATS the idle pooled
connections pinned every one of the server's 400 worker threads. New
origin connections then waited in the listen backlog (over 800 deep)
while no work was being done, ATS stalled, and the replay crawled at
about 700 requests per second against a 15,000 rps target.

This patch addresses this by parking idle sessions. When a worker's
poll for the next request times out and the session has no buffered
input or in-flight work, the worker hands the session to a single
watcher thread and returns to the pool. The watcher polls all parked
sockets and gives a session back to a worker as soon as it becomes
readable or closes, skipping the PROXY header and TLS handshake that
are already done. A new Session::is_idle() hook lets TLS account for
data OpenSSL has already decrypted, lets HTTP/2 require that no
streams are open, and keeps HTTP/3 sessions on their thread since QUIC
timers need driving.

With the same thread limits, the prod sim replay through ATS went from
about 0.7k to 10.6k rps, and to 14.4k rps once the client had enough
threads. A Uranium test covers a single-thread server serving a second
session while the first session's connection is idle.

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings October 12, 2026 20:24
@bneradt bneradt self-assigned this Oct 12, 2026
@bneradt bneradt added bug Something isn't working enhancement New feature or request labels Oct 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@bneradt
bneradt force-pushed the park-idle-server-sessions branch from e87ee5c to 085570a Compare October 12, 2026 20:32
verifier-server dedicates a worker thread to each accepted connection
for the connection's whole life, including the time it sits idle
between transactions. A proxy keeps pooled origin connections open
between requests, so in prod sim replays through ATS the idle pooled
connections pinned every one of the server's 400 worker threads. New
origin connections then waited in the listen backlog (over 800 deep)
while no work was being done, ATS stalled, and the replay crawled at
about 700 requests per second against a 15,000 rps target.

This patch addresses this by parking idle sessions. When a worker's
poll for the next request times out and the session has no buffered
input or in-flight work, the worker hands the session to a single
watcher thread and returns to the pool. The watcher polls all parked
sockets and gives a session back to a worker as soon as it becomes
readable or closes, skipping the PROXY header and TLS handshake that
are already done. A new Session::is_idle() hook lets TLS account for
data OpenSSL has already decrypted, lets HTTP/2 require that no
streams are open, and keeps HTTP/3 sessions on their thread since QUIC
timers need driving.

With the same thread limits, the prod sim replay through ATS went from
about 0.7k to 10.6k rps, and to 14.4k rps once the client had enough
threads. A Uranium test covers a single-thread server serving a second
session while the first session's connection is idle.

Co-Authored-By: Claude Opus 5.5 (low reasoning) <[email protected]>
@bneradt
bneradt force-pushed the park-idle-server-sessions branch from 085570a to b0e911f Compare October 12, 2026 20:39
@bneradt
bneradt merged commit f92516e into yahoo:master Oct 12, 2026
6 checks passed
@bneradt
bneradt deleted the park-idle-server-sessions branch October 12, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants