Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

listen() backlog upper limits

Tags:

c

linux

tcp

backlog

even though a lot was said on the topic, I am still stumped.

I experiment with a monster linux server capable of handling proper load ramps, presumably many thousand connections a second. Now, if i check default listen() queue:

#cat /proc/sys/net/core/somaxconn
128

which couldn't be actual queue size at all. I suspect it might be a legacy, and actual size is given by this:

#cat /proc/sys/net/ipv4/tcp_max_syn_backlog
2048

However, man tcp says the latter is connections awaiting ACK from clients, which is different from total number of connections having not yet been accepted, which is what listen() backlog is.

So my question is how can I increase listen() backlog, and how to get/set upper limit of it (right before kernel recompilation)?

like image 590
wick Avatar asked Mar 05 '26 02:03

wick


2 Answers

somaxconn is the number of complete connections waiting.

tcp_max_syn_backlog is the number of incomplete connections waiting.

They aren't the same thing. It's all described in the man page.

like image 88
user207421 Avatar answered Mar 06 '26 15:03

user207421


You increase it by following these instructions: https://serverfault.com/questions/271380/how-can-i-increase-the-value-of-somaxconn - basically by using sysctl.

And yes, somaxconn is the cap on listen backlog.

like image 22
John Zwinck Avatar answered Mar 06 '26 16:03

John Zwinck