Repository navigation
Park idle server sessions off worker threads - #403
Merged
Merged
Conversation
bneradt
force-pushed
the
park-idle-server-sessions
branch
from
October 12, 2026 20:32
e87ee5c to
085570a
Compare
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
force-pushed
the
park-idle-server-sessions
branch
from
October 12, 2026 20:39
085570a to
b0e911f
Compare
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.
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