Summary from book <<System Performance 2rd>>
, Network Chapter.
Tuning depends on the network workload characterization, the available tunables also vary between versions of OS.
Check TCP settings by:
1 | sysctl -a | grep -i tcp |
Write changes to the file /etc/sysctl.conf
, reload the settings via
sysctl -p
command and it will take effect without rebooting.
Production Example
Socket and TCP buffer in bytes, may need to be set to 16M or higher to support full-speed 10GbE connections:
1 | net.core.rmem_max = 16777216 |
Enable auto-tuning TCP receive buffer:
1 | net.ipv4.tcp_moderate_rcvbuf = 1 |
TCP read and write buffer auto-tunning in bytes (min, default, max):
1 | net.ipv4.tcp_rmem = 4096 87380 16777216 |
TCP backlog, for half-open connections:
1 | net.ipv4.tcp_max_syn_backlog = 4096 |
Listen backlog, for passing connections to accept:
1 | net.core.somaxconn = 1024 |
Above two attributes with bigger value can better handle burst of load.
Device backlog queue length, per CPU (for example for 10Gbe NICs):
1 | net.core.netdev_max_backlog = 10000 |
TCP congestion control, Linux supports pluggable congestion control algorithms.
1 | # Check available ones. |
Other TCP options:
1 | # Improve performance over high latency network |
Queuing Disciplines
It is for network packets scheduling, manipluating, filtering and shaping, for example, control the packet loss rate.
1 | # Check default |
Many Linux distros have already switched to fq_codel
as the default, it
provides good performance in most cases.