Linux调优(网络)

  • 定义socket接受缓冲大小
net.core.rmem_default = N  #接受
net.core.rmem_max = N
net.core.wmem_default = N  #发送
net.core.wmem_max = N
  • 调整buffer大小
# ping 192.168.100.1
PING 192.168.100.1 (192.168.100.1) 56(84) bytes of data.
64 bytes from 192.168.100.1: icmp_seq=1 ttl=64 time=0.038 ms
64 bytes from 192.168.100.1: icmp_seq=2 ttl=64 time=0.033 ms
^C
--- 192.168.100.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.033/0.035/0.038/0.006 ms

取:avg = 0.035
总buffer = 网卡支持的最大带宽 * 延迟的平均值
total_buffer(KB) = 1000(千兆网卡)*1024(bps)/8 * 0.035(ms) * 10^-3
  • 自动调整tcp窗口大小
tcp_window_scaling = 1
  • tcp接受或者发送的缓冲大小
net.ipv4.tcp_mem min defalut max
net.ipv4.tcp_rmem min defalut max
net.ipv4.tcp_wmem min defalut max
  • 分片重组缓冲大小
net.ipv4.ipfrag_high_thresh  #用于作tcp分片重组的最大缓冲值
net.ipv4.ipfrag_low_thresh
net.ipv4.ipfrag_time  #默认30s
  • 统计数据统计
# netstat -s
  • 是否使用处于TIME-WAIT状态的连接来处理新请求
net.ipv4.tcp_tw_reuse
  • 减免syn攻击
tcp_syncookies
  • tcp孤儿进程 (没有关联到fd的tcp连接),定义tcp孤儿的保留数,通常需要增大
tcp_max_orphans
  • 定义FIN-WAIT-2的连接超时时间
tcp_fin_timeout
  • 内核同时持有tcp timeout连接的数量,通常需要增大
tcp_max_tw_buckets
  • listen状态的可用大小,后援队列大小
net.core.somaxconn
  • 允许打开的端口范围
net.ipv4.ip_local_port_range = 1024 65000
  • ack重试次数
net.ipv4.tcp_synack_retries = 1
posted @ 2019-06-22 14:05  生生不息.连绵不绝  阅读(493)  评论(0编辑  收藏  举报