Linux sysctl Tuning

Version 1

    You can use the Linux sysctl command to modify default system network parameters that are set by the operating system in order to improve IPv4 and IPv6 traffic performance. Note, however, that changing the network parameters may yield different results on different systems. The results are significantly dependent on the CPU and chipset efficiency.




    Tuning the Network Adapter for Improved IPv4 Traffic Performance

    The following changes are recommended for improving IPv4 traffic performance:

    1. Disable the TCP timestamps option for better CPU utilization:

    # sysctl -w net.ipv4.tcp_timestamps=0

    2. Enable the TCP selective acks option for better throughput:

    # sysctl -w net.ipv4.tcp_sack=1

    3. Increase the maximum length of processor input queues:

    # sysctl -w net.core.netdev_max_backlog=250000


    4. Increase the TCP maximum and default buffer sizes using setsockopt():

    # sysctl  -w net.core.rmem_max=4194304

    # sysctl  -w net.core.wmem_max=4194304

    # sysctl  -w net.core.rmem_default=4194304

    # sysctl  -w net.core.wmem_default=4194304

    # sysctl  -w net.core.optmem_max=4194304


    5. Increase memory thresholds to prevent packet dropping:

    # sysctl -w net.ipv4.tcp_rmem="4096 87380 4194304"

    # sysctl -w net.ipv4.tcp_wmem="4096 65536 4194304"


    6. Enable low latency mode for TCP:

    # sysctl -w net.ipv4.tcp_low_latency=1


    The following variable is used to tell the kernel how much of the socket buffer space should be used for TCP window size, and how much to save for an application buffer.

    # sysctl -w net.ipv4.tcp_adv_win_scale=1

    A value of 1 means the socket buffer will be divided evenly between TCP windows size and application.

    Preserving Your sysctl Settings after a Reboot

    To preserve your performance settings after a reboot, you need to add them to the file

    /etc/sysctl.conf as follows:

    <sysctl name1>=<value1>

    <sysctl name2>=<value2>

    <sysctl name3>=<value3>

    <sysctl name4>=<value4>


    For example, Tuning the Network Adapter for Improved IPv4 Traffic Performance (on page 16) lists the following setting to disable the TCP timestamps option:

    # sysctl -w net.ipv4.tcp_timestamps=0


    In order to keep the TCP timestamps option disabled after a reboot, add the following line to