I'm tuning sysctl.conf
.
According to an optimization guide on linode's website, the following is a sane value to set in sysctl.conf
:
net.ipv4.tcp_max_syn_backlog = 3240000
However, the same value in an archlinux optimization guide is:
net.ipv4.tcp_max_syn_backlog = 65536
Lastly, on another optimization blog (that is old but still SEOs quite high on Google), the value is touted to be:
net.ipv4.tcp_max_syn_backlog = 4096
All these ball parks are wildly different. What's the reasoning behind setting this value to a high number (vs a low number)? Which one should is the actual 'sane' value to start with?
Best Answer
It mainly depends on how much traffic you're running through you server(s). There are several important questions:
nginx
,haproxy
,varnish
You should be monitoring:
which is a symptom that your server is dropping packets (because e.g. the backlog queue is full).
Netstat statistics are exported to
/proc/net/netstat
where the stat is calledListenDrops
. It might be easier to parse with a script, or use something like:to get human readable names of stats. You should be able to collect this data using e.g. telegraf, collectd or prometheus.
Kernel tuning
net.ipv4.tcp_max_syn_backlog
- How many half-open connections for which the client has not yet sent an ACK response can be kept in the queue (source).net.core.somaxconn
The maximum number of connections that can be queued for acceptancenet.core.netdev_max_backlog
The maximum number of packets in the receive queue that passed through the network interface and are waiting to be processed by the kernel.These settings are tightly connected with number of opened files (as in Linux each new connection will open 2 file handles). You can check your limits using:
Which means that the server has
8160
opened files out of3270712
.