I tried setting Linux kernel. After editing /etc/sysctl.conf and executing the sysctl -p
it shows error
Invalid argument" setting key "net.core.somaxconn"
Linux distribution: Ubuntu 12.04.4 LTS, x86_64, 3.2.0-60-generic
$ cat /etc/sysctl.conf
net.ipv4.conf.eth0.arp_notify = 1
vm.swappiness = 0
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.somaxconn = 262144
net.core.netdev_max_backlog = 262144
fs.file-max = 1048576
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_max_syn_backlog = 409600
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_max_orphans = 262144
Can I increase the net.core.somaxconn
to 262144
?
Add net. core. somaxconn=1024 to /etc/sysctl. conf for it to become permanent (be reapplied after booting).
net. core. somaxconn : An upper limit for the value of the backlog parameter passed to the listen(2) function. If the backlog argument is greater than the value of /proc/sys/net/core/somaxconn , then it is silently truncated to this limit.
net. core. netdev_max_backlogThis parameter sets the maximum size of the network interface's receive queue. The queue is used to store received frames after removing them from the network adapter's ring buffer.
Same issue I got into when I tried to fine tune my nginx. This is the problem with the patch that been made to Ubuntu kernel. The
sk_max_ack_backlog field of the sock structure is defined as unsigned short.
Therefore, the backlog argument in inet_listen()
shouldn't exceed USHRT_MAX
. The backlog argument in the listen()
syscall is truncated to the somaxconn
value. So, the somaxconn
value shouldn't exceed 65535
(USHRT_MAX
).
So in short to make your net.core.somaxconn
work you should not give value greater then 65535
net.core.somaxconn = 65535
This is sad but we have to live with it until unless you are ok to repatch your kernel: https://lists.ubuntu.com/archives/kernel-team/2013-October/033041.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With