网络相关的内核可调参数

先备份 sysctl.conf,然后在文件里修改

  • ip_default_ttl

ip报文的time to live值,表示报文可以在网络中存活的跳数
默认值64,一般32就够了

ipfrag

IP Fragment,ip 分段

  • ipfrag_high_thresh、ipfrag_low_thresh

用来组装分段的IP包的最大内存量
默认比例是4:3

[root@vnc-server ~]# cat /proc/sys/net/ipv4/ipfrag_high_thresh
4194304
[root@vnc-server ~]# cat /proc/sys/net/ipv4/ipfrag_low_thresh
3145728

  • ipfrag_time

报存一个IP分片在内存中的时间,默认30s

  • ipfrag_secret_interval

refer to: IP分片报文的接收和重组

refer to: IP分片

inet_peer

refer to : https://www.frozentux.net/ipsysctl-tutorial/chunkyhtml/inetpeerstorage.html

  • inet_peer_threshold
  • inet_peer_maxttl
  • inet_peer_minttl

TCP变量

refer to: 内核TCP优化的相关参数

其他

  • 优化系统套接字缓冲区

net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

  • 优化TCP接收/发送缓冲区

net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216

  • 优化网络设备接收队列

net.core.netdev_max_backlog = 30000

  • 关闭路由相关功能

find /proc/ | grep net.ipv4.conf | grep -E "route|redirect"

优化TCP协议栈

  • 打开TCP SYN cookie 选项,有助于保护服务器免受 SynFlood 攻击

net.ipv4.tcp_syncookies = 1

  • 打开TIME-WAIT套接字重用功能,对于存在大量连接的web服务器非常有效

net.ipv4.tcp_tw_reuse = 1

recycle 选项在 openEuler 中找不到。

  • 减少处于FIN-WAIT-2连接状态的时间,使系统可以处理更多的连接

net.ipv4.tcp_fin_timeout = 10

  • 减少TCP KeepAlive 连接侦测的时间

net.ipv4.tcp_keepalive_time = 7200

默认值7200,可以考虑改成1800

  • 增加 TCP SYN 队列长度

net.ipv4.tcp_max_syn_backlog = 262144

默认值2048,可以修改为8192

  • 增加 TCP Accept 队列长度

net.core.somaxconn = 1024

默认是128,可以修改为4096

posted @ 2022-03-15 17:43  武平宁  阅读(300)  评论(0)    收藏  举报