1

I want to increase the maximum number of connections that can be queued for acceptance by NGINX, for this nginx documentation suggested to increase the somaxconn.

1) what are the min and max limits?

2) does the limit depend on the system configuration like ram, cores?

3

A quick search mentioned that in old kernels net.core.somaxconn was an unsigned 16 bit integer so between 0 and 65535, with a value of 128 as the default and that higher values would silently get truncated to 65535, but no mention if/when that was changed and to what.

On my CentOS test system with kernel 3.10.0 still no value beyond 65535 is accepted.

sysctl net.core.somaxconn=65536
sysctl: setting key "net.core.somaxconn": Invalid argument

I have no idea what the real-word impact/requirements are when a large limit is set and reached.

  • 1
    The listen(2) man page says: "If a connection request arrives when the queue is full, the client may receive an error with an indication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may be ignored so that a later reattempt at connection succeeds." But if your queue has gotten to 65535 waiting connections, you've got much bigger problems. – Michael Hampton Apr 19 at 16:24
0

I think you can't assign beyond 65,535 because of variable type, so values are bound with data type in C or any other languages. I agree with @HBruijn { struct socket *sock; int err, fput_needed; int somaxconn;

    sock = sockfd_lookup_light(fd, &err, &fput_needed);
    if (sock) {
            somaxconn = sock_net(sock->sk)->core.sysctl_somaxconn;
            if ((unsigned int)backlog > somaxconn)
                    backlog = somaxconn;

            err = security_socket_listen(sock, backlog);
            if (!err)
                    err = sock->ops->listen(sock, backlog);

            fput_light(sock->file, fput_needed);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.