Modifying Network Parameters
Purpose
Modify some parameter settings at the OS layer to improve server performance.
Procedure
Linux Parameter |
Description |
Default Value |
Recommended Value |
Commands |
|---|---|---|---|---|
tcp_max_syn_backlog |
Maximum number of clients that can receive SYN (synchronization) packets. |
2048 |
8192. |
echo 8192 > /proc/sys/net/ipv4/tcp_max_syn_backlog echo 1024 > /proc/sys/net/core/somaxconn echo 16777216 > /proc/sys/net/core/rmem_max echo 16777216 > /proc/sys/net/core/wmem_max echo 4096 87380 16777216> /proc/sys/net/ipv4/tcp_rmem echo 4096 65536 16777216> /proc/sys/net/ipv4/tcp_wmem echo 360000 > /proc/sys/net/ipv4/tcp_max_tw_buckets |
net.core.somaxconn |
Maximum number of clients that can process data in the server, that is, the maximum number of connections. |
128 |
1024. |
|
net.core.rmem_max |
Maximum size of the socket receive buffer, in bytes. |
229376 |
16777216. |
|
net.core.wmem_max |
Maximum size of the socket send buffer, in bytes. |
229376 |
16777216. |
|
net.ipv4.tcp_rmem |
Size of the read buffer. The three numbers indicate the minimum, default, and maximum size of the read buffer. |
4096 87380 6291456 |
4096 87380 16777216. |
|
net.ipv4.tcp_wmem |
Size of the write buffer. The three numbers indicate the minimum, default, and maximum size of the write buffer. |
4096 16384 4194304 |
4096 65536 16777216. |
|
net.ipv4.max_tw_buckets |
Maximum number of TIME_WAIT sockets that can be retained by the system at the same time. |
2048 |
360000. |
Enable the NIC interrupt aggregation function to reduce the number of NIC interrupts and CPU overhead. Specific parameters are to be explored in actual projects.
ethtool -C ethx adaptive-rx off adaptive-tx off rx-usecs 32 tx-usecs 32
Adjust the NIC buffer to optimize the NIC performance.
Adjust the NIC buffer. Replace ethx with the actual NIC.
ethtool -G ethx rx 4096
ethtool -G ethx rx 4096