From 85ec3963bc13116c42b04ab5a47bb27b5a7510e6 Mon Sep 17 00:00:00 2001 From: yhirose Date: Thu, 30 Jul 2026 17:18:43 -0400 Subject: [PATCH] Increase default listen backlog from 5 to 128 The accept queue was limited to 5 pending connections, which overflows easily under connection churn or a burst of simultaneous connects (LB health checks, thundering herd on restart). On overflow the kernel silently drops the ACK rather than failing fast, so clients stall on SYN/ACK retransmission backoff. Benchmark (bombardier -c 10 -d 10s, 3 trials, interleaved with the old binary) shows max latency dropping from 48-89ms to 5.8-11.2ms, while p99 is unchanged - the fix affects only the extreme tail, as expected. --- httplib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httplib.h b/httplib.h index 1c98cc8..3b8e0b6 100644 --- a/httplib.h +++ b/httplib.h @@ -182,7 +182,7 @@ #endif #ifndef CPPHTTPLIB_LISTEN_BACKLOG -#define CPPHTTPLIB_LISTEN_BACKLOG 5 +#define CPPHTTPLIB_LISTEN_BACKLOG 128 #endif #ifndef CPPHTTPLIB_MAX_LINE_LENGTH