Repository navigation
Raise the HTTP server's listen backlog to 32 - #27
Merged
ChrisCummins merged 2 commits intoOct 27, 2026
Merged
Conversation
ThreadingHTTPServer listens with socketserver's default backlog of 5. A burst of connections beyond that, arriving before the accept loop takes them, is reset on macOS and has its SYN dropped on Linux, so the client never reaches the admission check and its 429. This made the admission steps in protocol_test.py and test_serving.py fail intermittently. The admission limit is unchanged.
tc3oliver
marked this pull request as ready for review
October 24, 2026 09:52
ChrisCummins
approved these changes
Oct 27, 2026
ChrisCummins
left a comment
Contributor
There was a problem hiding this comment.
Nice fix. Thanks @tc3oliver!
Cheers,
Chris
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.
Fixes #26.
ThreadingHTTPServerlistens with a backlog of 5. Connections beyond that, arriving before the accept loop takes them, are reset (macOS) or dropped (Linux) before any handler runs, so a client in a burst can getConnectionResetErrorinstead of a 429. This setsrequest_queue_size = 32.32 leaves room for the 9 admitted requests, refused ones and
/healthpolls, so a burst larger than the admission limit still gets a 429 rather than a reset. 16 also passed the A/B in #26; 64 is not needed. Admission (BoundedSemaphore(9)), the scheduler, 429/503 handling, cancellation and shutdown are unchanged.Tests
test_listen_backlog_holds_a_burst_of_connections: stops the accept loop and opens 16 connections. Fails onmainat the 6th connect (ConnectionResetError), passes with this change.main, 4 rotated rounds per value: backlog 5 failedprotocol_test.py2/4 andtest_serving.py2/4; 16, 32 and 64 failed 0/4. Details in HTTP listen backlog may cause flaky queue admission tests #26.make testpasses on M4 Max: engine 66 passed, 1 skipped (device-gated, same onmain), smoke, packaging andprotocol_test.py, which covers the 8 queued requests, the 429, cancellation and disconnect.test_serving.pycovers queue capacity, disconnect, shutdown and worker failure.Four A/B rounds and one
make testdo not prove the flake is gone, only that it did not recur in those runs.