-
我的服务器默认网络堆栈配置如下:
# default maximum Linux TCP buffer sizes is calculated automatically based on system memory $ cat /proc/sys/net/ipv4/tcp_mem 22755 30340 45510 $ sysctl net.ipv4.tcp_rmem net.ipv4.tcp_rmem = 4096 87380 6291456 $ sysctl net.ipv4.tcp_wmem net.ipv4.tcp_wmem = 4096 16384 4194304 # The default and maximum amount for the receive socket memory $ cat /proc/sys/net/core/rmem_default 212992 $ cat /proc/sys/net/core/rmem_max 212992 # The default and maximum amount for the send socket memory $ cat /proc/sys/net/core/wmem_default 212992 $ cat /proc/sys/net/core/wmem_max 212992 # The maximum amount of option memory buffers $ cat /proc/sys/net/core/optmem_max 20480 # there is a feature for auto tuning, which dynamically adjusts the TCP buffer size till the maximum value is attained. This feature is turned on by default and I recommend that it be left turned on. $ cat /proc/sys/net/ipv4/tcp_moderate_rcvbuf 1 # Before processing the data by the TCP/UDP layer, your system puts the data in the kernel queue. The net.core.netdev_max_backlog value specifies the maximum number of packets to put in the queue before delivery to the upper layer. $ sysctl net.core.netdev_max_backlog net.core.netdev_max_backlog = 1000 # MTU size $ ip addr 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 ...
-
提高网卡MTU大小
ifconfig eth0 mtu 9000
-
增大kernel socket buffer大小:
# 暂时 sysctl -w net.core.wmem_default=262144 sysctl -w net.core.wmem_max=4194304 sysctl -w net.core.rmem_default=262144 sysctl -w net.core.rmem_max=4194304 # 永久 echo 'net.core.wmem_default=262144' >> /etc/sysctl.conf echo 'net.core.wmem_max=4194304' >> /etc/sysctl.conf echo 'net.core.rmem_default=262144' >> /etc/sysctl.conf echo 'net.core.rmem_max=4194304' >> /etc/sysctl.conf sysctl -p
-
TCP/UDP处理
# 暂时 sysctl -w net.ipv4.tcp_rmem=" 4096 87380 12582912" sysctl -w net.ipv4.tcp_wmem=" 4096 16384 6291456" # 永久: echo 'net.ipv4.tcp_rmem=4096 87380 12582912' >> /etc/sysctl.conf echo 'net.ipv4.tcp_wmem=4096 16384 6291456' >> /etc/sysctl.conf sysctl -p
Reference