可以修改/etc/sysctl.conf进行网络堆栈配置,进行网络性能优化
- # sysctl settings are defined through files in
- # /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
- #
- # Vendors settings live in /usr/lib/sysctl.d/.
- # To override a whole file, create a new file with the same in
- # /etc/sysctl.d/ and put new settings there. To override
- # only specific settings, add a file with a lexically later
- # name in /etc/sysctl.d/ and put new settings there.
- #
- # For more information, see sysctl.conf(5) and sysctl.d(5).
- # controls whether the system should reboot if it detects a hung task
- # 1 means reboot after hung_task_timeout_secs after a hung task is detected
- # default value is 0
- kernel.hung_task_panic = 0
- # controls how long to reboot after a hung task is detected
- # default is 600 seconds.
- # note: this only matters if kernel.hung_task_panic=1
- kernel.hung_task_timeout_secs = 600
- net.ipv4.tcp_timestamps=0
- net.ipv4.tcp_sack=1
- net.core.netdev_max_backlog=250000
- net.core.rmem_max=4194304
- net.core.wmem_max=4194304
- net.core.rmem_default=4194304
- net.core.wmem_default=4194304
- net.ipv4.tcp_rmem="4096 65536 4194304"
- net.ipv4.tcp_wmem="4096 65536 4194304"
- net.ipv4.tcp_low_latency=1
参数含义:
tcp_timestamps:时间戳,为0禁用时间戳
tcp_sack:选择应答,为1表示开启
netdev_max_backlog:当网卡接收数据包的速度大于内核处理的速度时,会有一个队列保存这些数据包,该参数表示该队列的最大值
rmem_max:内核套接字接收缓存区最大的大小
wmem_max:内核套接字发送缓存区最大大小
rmem_default:内核套接字接收缓存区默认大小
wmem_default:内核套接字发送缓存区默认大小
tcp_rmem:TCP接受缓存(用于TCP接收滑动窗口)的最小值,默认值,最大值
tcp_wmem:TCP发送缓存(用于TCP发送滑动窗口)的最小值,默认值,最大值
tcp_low_latency:TCP响应延迟,0为禁用低延迟,这样配置后能够获取更高的吞吐量