Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

serve: STRATA_HTTP_BACKLOG, test with 60 simultaneous connections

Niko1221c34dd571435f
diff --git a/serve/server.py b/serve/server.py
index fbf28a6e4..93ef32690 100644
--- a/serve/server.py
+++ b/serve/server.py
@@ -4969,7 +4969,8 @@ class Server(ThreadingHTTPServer):
allow_reuse_address = os.name != "nt"
# socketserver listens with a backlog of 5: a burst of 30-40 clients at once got "connection reset by peer" on the
# first ones (measured on 4 x R9700, also with one request at a time); the requests wait in the server, not the kernel
- request_queue_size = 256
+ # (STRATA_HTTP_BACKLOG overrides it)
+ request_queue_size = max(5, int(os.environ.get("STRATA_HTTP_BACKLOG") or 256))
def handle_error(self, request, client_address):
if not isinstance(sys.exc_info()[1], ConnectionError): # a client that hangs up needs no stack trace
diff --git a/serve/test_parallel.py b/serve/test_parallel.py
index 8420eef9f..a25ed442c 100644
--- a/serve/test_parallel.py
+++ b/serve/test_parallel.py
@@ -320,6 +320,24 @@ class ParallelService(unittest.TestCase):
self.start(8, says_groups=4, more=["--batch-groups", "1"]) # the opt-out
self.assertEqual(self.engine.slot_groups, 1)
+ def test_a_burst_of_connections_is_not_reset(self):
+ """30-40 clients at once got "connection reset by peer" with the listen backlog of 5 (4 x R9700 burst): the
+ server listens with a deep backlog (STRATA_HTTP_BACKLOG, 256), so 60 simultaneous requests all get answers."""
+ import serve.server as server
+ self.assertGreaterEqual(server.Server.request_queue_size, 64)
+ self.start(2)
+ errs, ok = [], []
+ def one(i):
+ try:
+ self.chat(f"burst {i}", max_tokens=8)
+ ok.append(i)
+ except Exception as e: # noqa: BLE001
+ errs.append(repr(e))
+ th = [threading.Thread(target=one, args=(i,)) for i in range(60)]
+ for t in th: t.start()
+ for t in th: t.join()
+ self.assertEqual((len(ok), errs[:2]), (60, []))
+
def test_stop_strings_in_a_batch_slot(self):
"""#454: a stop string cuts the answer in --batch mode too, and the slot is freed for the next request."""
self.start(2)