What is the maximum limit for "net.core.somaxconn" parameter?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux(RHEL) 8
  • Red Hat Enterprise Linux(RHEL) 7
  • Red Hat Enterprise Linux(RHEL) 6

Issue

What is the maximum limit for net.core.somaxconn parameter?

Resolution

  • somaxconn is a kernel parameter in Linux that determines the maximum number of connections that can be queued in the TCP/IP stack backlog per socket.

  • We can assign a 16 bits value which is equivalent to 65535 in RHEL 6 & RHEL 7 but in RHEL 8, we can increase the value to 32 bits.

Root Cause

  • In RHEL 6 & RHEL 7, the sk_max_ack_backlog field of the sock structure is defined as unsigned short which limits the values to 16 bits whose maximum value is 65535.
  • In RHEL 8, sk_max_ack_backlog field of the sock structure is defined as u32 which limits the values to 32 bits whose maximum value is 2147483647.
commit becb74f0acca19b5abfcb24dc602530f3deea66a
Author: Eric Dumazet <edumazet@google.com>
Date:   Thu Mar 19 19:04:21 2015 -0700

    net: increase sk_[max_]ack_backlog

    sk_ack_backlog & sk_max_ack_backlog were 16bit fields, meaning
    listen() backlog was limited to 65535.

    It is time to increase the width to allow much bigger backlog,
    if admins change /proc/sys/net/core/somaxconn &
    /proc/sys/net/ipv4/tcp_max_syn_backlog default values.

    Tested:

    echo 5000000 >/proc/sys/net/core/somaxconn
    echo 5000000 >/proc/sys/net/ipv4/tcp_max_syn_backlog

    Ran a SYNFLOOD test against a listener using listen(fd, 5000000)

    myhost~# grep request_sock_TCP /proc/slabinfo
    request_sock_TCP  4185642 4411940    304   13    1 : tunables   54   27    8 : slabdata 339380 339380      0

    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments