Know the size of accept pending connections queue in GNU/Linux

Jon Ander Ortiz Durántez picture Jon Ander Ortiz Durántez · Jan 27, 2011 · Viewed 9.9k times · Source

In a typical C network server implementation, the size of the accept pending queue can be set with listen. When a new connection incomes and there is no more space in the queue, ECONNREFUSED is send to the client or the request is ignored.

Is any way to know the state of this queue? It's important because in a high load event-based daemon, we're detecting some retries from the client, and we suspect that this queue goes full and the connection tries are being ignored.

Thanks in advance.

Answer

ramrunner picture ramrunner · Feb 15, 2011

in linux: /proc/sys/net/ipv4/tcp_max_syn_backlog:

Maximal number of remembered connection requests, which are still did not receive an acknowledgment from connecting client.

Default value is 1024 for systems with more than 128Mb of memory, and 128 for low memory machines. If server suffers of overload, try to increase this number.

/proc/sys/net/core/somaxconn: Limit of socket listen() backlog, known in userspace as SOMAXCONN. Defaults to 128. See also tcp_max_syn_backlog for additional tuning for TCP sockets.

these are the relevant sysctls .. on openbsd that i am sitting now a quick sysctl -a reveals: net.inet.ip.maxqueue=300