Skip to content

Allow setting the listen backlog of server sockets - #3789

Open
sideeffffect wants to merge 4 commits into
typelevel:mainfrom
sideeffffect:listen-backlog
Open

sideeffffect wants to merge 4 commits into
typelevel:mainfrom
sideeffffect:listen-backlog

Conversation

@sideeffffect

@sideeffffect sideeffffect commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Enables setting the Backlog as a SocketOption. Before this, it was not configurable and users were at the mercy of the platform default (50 for OpenJDK).

SocketOption.backlog(n) requires n > 0. When not set, each provider keeps its existing default: the JDK default (50) for JDK sockets, 128 for JNR unix sockets, 0 on Scala Native, and the Node.js default on JS.

sideeffffect and others added 2 commits October 30, 2026 00:57
Server sockets were bound with the platform default backlog (50 on the
JVM, 0 on Native, 511 on Node.js) and there was no way to change it.
Under bursts of new connections, the kernel's accept queue overflows and
each dropped SYN costs the client a 1-3 s retransmit.

Add a `SocketOption.backlog` pseudo-option. When passed to
`Network.bind` (and the APIs built on it), it is removed from the
options applied to accepted sockets and used as the backlog when the
server socket starts listening: `bind(address, backlog)` on the JVM
(IP and unix sockets), `listen(fd, backlog)` on Native, and
`server.listen({ backlog })` on Node.js. Without it, the platform
default is used as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sideeffffect
sideeffffect marked this pull request as ready for review October 30, 2026 16:53
sideeffffect and others added 2 commits October 30, 2026 18:02
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant