Invalid argument setting key net.core.somaxconn
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
What is the difference between tcp_max_syn_backlog and somaxconn?
sysctl is an API. So you can just read the Linux kernel documentation for appropriate version:
tcp_max_syn_backlog - INTEGER
Maximal number of remembered connection requests, which have not
received an acknowledgment from connecting client.
The minimal value is 128 for low memory machines, and it will
increase in proportion to the memory of machine.
If server suffers from overload, try increasing this number.
somaxconn - INTEGER
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.
Let's consider a TCP-handshake.. tcp_max_syn_backlog
represents the maximal number of connections in SYN_RECV
queue. I.e. when your server received SYN, sent SYN-ACK and haven't received ACK yet. This is a separate queue of so-called "request sockets" - reqsk
in code (i.e. not fully-fledged sockets, "request sockets" occupy less memory. In this state we can save some memory and not yet allocate a full socket because the full connection may not be at all in the future if ACK will not arrive). The value of this queue is affected (see this post) by listen()
's backlog
argument and limited by tcp_max_syn_backlog
in kernel.
somaxconn
represents the maximal size of ESTABLISHED
queue. This is another queue.
Recall the previously mentioned SYN_RECV
queue - your server is waiting for ACK from client. When the ACK arrives the kernel roughly speaking makes the big full-fledged socket from "request socket" and moves it to ESTABLISHED queue. Then you can do accept()
on this socket. This queue is also affected by listen()
's backlog
argument and limited by somaxconn
in kernel.
Useful links: 1, 2.
Refresh net.core.somaxcomm (or any sysctl property) for docker containers
Just figured out how to solve this, now Elastic Beanstalk supports running a privileged containers and you just need to add the "privileged": "true"
to your Dockerrun.aws.json
as the following sample (please take a look at the container-1
):
{
"AWSEBDockerrunVersion": 2,
"containerDefinitions": [{
"name": "container-0",
"essential": "false",
"image": "ubuntu",
"memory": "512"
}, {
"name": "container-1",
"essential": "false",
"image": "ubuntu",
"memory": "512",
"privileged": "true"
}]
}
Please note that I duplicated this answer from another thread.
Error: bind EAFNOSUPPORT when trying to use udp6
I solved this issue by changing to
server = dgram.createSocket('udp4');
and setting my server ip to 0.0.0.0
I was not able to make udp6
work
Related Topics
Rename Multiple Files While Keeping the Same Extension on Linux
Why Can't I Sys_Write from a Pointer to Stack Memory, Using Int 0X80
How to Build Msi Package on a Linux Server
How to Print a Single Ascii Char
How to Copy an Array in Nasm X86 Assembly for Linux, Porting 16-Bit Dos Code
Diolan Dln-2 Spi Controller on X86_64 Platform
Split Files Using Tar, Gz, Zip, or Bzip2
How to Remove Folders with a Certain Name
Remove Redundant Paths from $Path Variable
Create a Symbolic Link of Directory in Ubuntu
Why How to Cast Sockaddr to Sockaddr_In
Does Socket Io Involve Disk Io