Expand description
Binding of TCP listeners with an operator-controllable accept queue.
The async runtime builds listeners through mio, which hardcodes the
listen(2) backlog to 128 with no way to override it. That queue has been
observed to overflow under a connection burst well before CPU saturates,
dropping connections the kernel could otherwise have queued. This module
binds the socket directly so the backlog can be set, defaulting to the
kernel’s ceiling.
Functions§
- bind_
with_ backlog - Binds a listening TCP socket at
listen, requesting an accept queue ofbacklogentries, or the kernel maximum whenbacklogisNone. The returned listener is in non-blocking mode, ready to hand to an async runtime. - kernel_
max_ backlog - Returns the kernel’s maximum accept-queue length, which is the largest
backlog
listen(2)will honor. A larger request is silently clamped down to this value. On Linux this isnet.core.somaxconn. Elsewhere, and when it cannot be read, returns a conservative default that the kernel will clamp down further if needed.