当前位置:   article > 正文

Linux TCP/IP内核参数调优,网络高延迟大吞吐(方案二)。_linux 网络延迟优化

linux 网络延迟优化

方案一:Linux TCP/IP内核参数调优,网络高延迟大吞吐。_net.ipv4.tcp_wmem_liulilittle的博客-CSDN博客

nano /etc/sysctl.conf

  1. vm.overcommit_memory=1
  2. net.core.rps_sock_flow_entries=32768 #rfs 设置此文件至同时活跃连接数的最大预期值
  3. #net.ipv4.icmp_echo_ignore_all=1 #禁止ping
  4. #net.ipv4.icmp_echo_ignore_broadcasts=1
  5. fs.file-max=1000000 # 系统级别的能够打开的文件句柄的数量
  6. fs.inotify.max_user_instances=65536
  7. #开启路由转发
  8. net.ipv4.conf.all.route_localnet=1
  9. net.ipv4.ip_forward=1
  10. net.ipv4.conf.all.forwarding=1
  11. net.ipv4.conf.default.forwarding=1
  12. net.ipv6.conf.all.forwarding = 1
  13. net.ipv6.conf.default.forwarding = 1
  14. net.ipv6.conf.lo.forwarding = 1
  15. net.ipv6.conf.all.disable_ipv6 = 0
  16. net.ipv6.conf.default.disable_ipv6 = 0
  17. net.ipv6.conf.lo.disable_ipv6 = 0
  18. net.ipv6.conf.all.accept_ra = 2
  19. net.ipv6.conf.default.accept_ra = 2
  20. net.ipv4.conf.all.accept_redirects=0
  21. net.ipv4.conf.default.accept_redirects=0
  22. net.ipv4.conf.all.secure_redirects=0
  23. net.ipv4.conf.default.secure_redirects=0
  24. net.ipv4.conf.all.send_redirects=0
  25. net.ipv4.conf.default.send_redirects=0
  26. net.ipv4.conf.default.rp_filter=0
  27. net.ipv4.conf.all.rp_filter=0
  28. #ARP回应的级别
  29. #net.ipv4.conf.all.arp_ignore=2
  30. #net.ipv4.conf.default.arp_ignore=2
  31. #net.ipv4.conf.all.arp_announce=2
  32. #net.ipv4.conf.default.arp_announce=2
  33. net.ipv4.neigh.default.gc_stale_time=60 #ARP缓存的存活时间
  34. net.ipv4.tcp_syncookies=1 #开启SYN Cookies。当出现SYN等待队列溢出时,启用cookies来处理
  35. net.ipv4.tcp_retries1=3
  36. net.ipv4.tcp_retries2=8
  37. net.ipv4.tcp_syn_retries=2 #SYN重试次数
  38. net.ipv4.tcp_synack_retries=2 #SYNACK重试次数
  39. net.ipv4.tcp_tw_reuse=1 #开启TIME-WAIT sockets重用
  40. net.ipv4.tcp_fin_timeout=15 #保持在FIN-WAIT-2状态的时间
  41. net.ipv4.tcp_max_tw_buckets=32768 #系统同时保持TIME_WAIT socket的数量
  42. #net.core.busy_poll=50
  43. #net.core.busy_read=50
  44. net.core.dev_weight=4096
  45. net.core.netdev_budget=65536
  46. net.core.netdev_budget_usecs=4096
  47. net.ipv4.tcp_max_syn_backlog=262144 #对于还未获得对方确认的连接请求,可保存在队列中的最大数目
  48. net.core.netdev_max_backlog=32768 #网口接收数据包比内核处理速率快状态队列的数量
  49. net.core.somaxconn=32768 #每个端口最大的监听队列的数量
  50. net.ipv4.tcp_notsent_lowat=16384
  51. net.ipv4_timestamps=0 #TCP时间戳的支持
  52. net.ipv4.tcp_keepalive_time=600 #TCP发送keepalive探测消息的间隔时间(秒)
  53. net.ipv4.tcp_keepalive_probes=5 #TCP发送keepalive探测确定连接已经断开的次数
  54. net.ipv4.tcp_keepalive_intvl=15 #探测消息未获得响应时,重发该消息的间隔时间
  55. vm.swappiness=1
  56. net.ipv4.route.gc_timeout=100
  57. net.ipv4.neigh.default.gc_thresh1=1024 #最小保存条数。当邻居表中的条数小于该数值,则 GC 不会做任何清理
  58. net.ipv4.neigh.default.gc_thresh2=4096 #高于该阈值时,GC 会变得更激进,此时存在时间大于 5s 的条目会被清理
  59. net.ipv4.neigh.default.gc_thresh3=8192 #允许的最大临时条目数。当使用的网卡数很多,或直连了很多其它机器时考虑增大该参数。
  60. net.ipv6.neigh.default.gc_thresh1=1024
  61. net.ipv6.neigh.default.gc_thresh2=4096
  62. net.ipv6.neigh.default.gc_thresh3=8192
  63. net.netfilter.nf_conntrack_max=262144
  64. net.nf_conntrack_max=262144
  65. net.netfilter.nf_conntrack_tcp_timeout_established=36000 #ESTABLISHED状态连接的超时时间
  66. # TCP窗口
  67. net.ipv4.tcp_fastopen=3 # 开启TCP快速打开
  68. net.ipv4.tcp_autocorking=0
  69. net.ipv4.tcp_slow_start_after_idle=0 #关闭TCP的连接传输的慢启动
  70. net.ipv4.tcp_no_metrics_save=1
  71. net.ipv4.tcp_ecn=0
  72. net.ipv4.tcp_frto=0
  73. net.ipv4.tcp_mtu_probing=0
  74. net.ipv4.tcp_rfc1337=0
  75. net.ipv4.tcp_sack=1
  76. net.ipv4.tcp_fack=1
  77. net.ipv4.tcp_window_scaling=1
  78. net.ipv4.tcp_adv_win_scale=1
  79. net.ipv4.tcp_moderate_rcvbuf=1
  80. net.core.rmem_max=33554432
  81. net.core.wmem_max=33554432
  82. net.ipv4.tcp_rmem=4096 87380 33554432
  83. net.ipv4.tcp_wmem=4096 16384 33554432
  84. net.ipv4.udp_rmem_min=8192
  85. net.ipv4.udp_wmem_min=8192
  86. net.ipv4.tcp_mem=262144 1048576 4194304
  87. net.ipv4.udp_mem=262144 524288 1048576
  88. # BBR
  89. net.ipv4.tcp_congestion_control=bbr
  90. net.core.default_qdisc=fq

sysctl -p

另类设置

  1. vm.overcommit_memory=1
  2. net.core.rps_sock_flow_entries=32768 #rfs 设置此文件至同时活跃连接数的最大预期值
  3. #net.ipv4.icmp_echo_ignore_all=1 #禁止ping
  4. #net.ipv4.icmp_echo_ignore_broadcasts=1
  5. fs.file-max=1000000 # 系统级别的能够打开的文件句柄的数量
  6. fs.inotify.max_user_instances=65536
  7. #开启路由转发
  8. net.ipv4.conf.all.route_localnet=1
  9. net.ipv4.ip_forward=1
  10. net.ipv4.conf.all.forwarding=1
  11. net.ipv4.conf.default.forwarding=1
  12. net.ipv6.conf.all.forwarding = 1
  13. net.ipv6.conf.default.forwarding = 1
  14. net.ipv6.conf.lo.forwarding = 1
  15. net.ipv6.conf.all.disable_ipv6 = 0
  16. net.ipv6.conf.default.disable_ipv6 = 0
  17. net.ipv6.conf.lo.disable_ipv6 = 0
  18. net.ipv6.conf.all.accept_ra = 2
  19. net.ipv6.conf.default.accept_ra = 2
  20. net.ipv4.conf.all.accept_redirects=0
  21. net.ipv4.conf.default.accept_redirects=0
  22. net.ipv4.conf.all.secure_redirects=0
  23. net.ipv4.conf.default.secure_redirects=0
  24. net.ipv4.conf.all.send_redirects=0
  25. net.ipv4.conf.default.send_redirects=0
  26. net.ipv4.conf.default.rp_filter=0
  27. net.ipv4.conf.all.rp_filter=0
  28. #ARP回应的级别
  29. #net.ipv4.conf.all.arp_ignore=2
  30. #net.ipv4.conf.default.arp_ignore=2
  31. #net.ipv4.conf.all.arp_announce=2
  32. #net.ipv4.conf.default.arp_announce=2
  33. net.ipv4.neigh.default.gc_stale_time=60 #ARP缓存的存活时间
  34. net.ipv4.tcp_syncookies=1 #开启SYN Cookies。当出现SYN等待队列溢出时,启用cookies来处理
  35. net.ipv4.tcp_retries1=3
  36. net.ipv4.tcp_retries2=8
  37. net.ipv4.tcp_syn_retries=2 #SYN重试次数
  38. net.ipv4.tcp_synack_retries=2 #SYNACK重试次数
  39. net.ipv4.tcp_tw_reuse=1 #开启TIME-WAIT sockets重用
  40. net.ipv4.tcp_fin_timeout=15 #保持在FIN-WAIT-2状态的时间
  41. net.ipv4.tcp_max_tw_buckets=32768 #系统同时保持TIME_WAIT socket的数量
  42. #net.core.busy_poll=50
  43. #net.core.busy_read=50
  44. net.core.dev_weight=4096
  45. net.core.netdev_budget=65536
  46. net.core.netdev_budget_usecs=4096
  47. net.ipv4.tcp_max_syn_backlog=262144 #对于还未获得对方确认的连接请求,可保存在队列中的最大数目
  48. net.core.netdev_max_backlog=32768 #网口接收数据包比内核处理速率快状态队列的数量
  49. net.core.somaxconn=32768 #每个端口最大的监听队列的数量
  50. net.ipv4.tcp_notsent_lowat=16384
  51. net.ipv4_timestamps=0 #TCP时间戳的支持
  52. net.ipv4.tcp_keepalive_time=600 #TCP发送keepalive探测消息的间隔时间(秒)
  53. net.ipv4.tcp_keepalive_probes=5 #TCP发送keepalive探测确定连接已经断开的次数
  54. net.ipv4.tcp_keepalive_intvl=15 #探测消息未获得响应时,重发该消息的间隔时间
  55. vm.swappiness=1
  56. net.ipv4.route.gc_timeout=100
  57. net.ipv4.neigh.default.gc_thresh1=1024 #最小保存条数。当邻居表中的条数小于该数值,则 GC 不会做任何清理
  58. net.ipv4.neigh.default.gc_thresh2=4096 #高于该阈值时,GC 会变得更激进,此时存在时间大于 5s 的条目会被清理
  59. net.ipv4.neigh.default.gc_thresh3=8192 #允许的最大临时条目数。当使用的网卡数很多,或直连了很多其它机器时考虑增大该参数。
  60. net.ipv6.neigh.default.gc_thresh1=1024
  61. net.ipv6.neigh.default.gc_thresh2=4096
  62. net.ipv6.neigh.default.gc_thresh3=8192
  63. net.netfilter.nf_conntrack_max=262144
  64. net.nf_conntrack_max=262144
  65. net.netfilter.nf_conntrack_tcp_timeout_established=36000 #ESTABLISHED状态连接的超时时间
  66. # TCP窗口
  67. net.ipv4.tcp_fastopen=3 # 开启TCP快速打开
  68. net.ipv4.tcp_autocorking=0
  69. net.ipv4.tcp_slow_start_after_idle=0 #关闭TCP的连接传输的慢启动
  70. net.ipv4.tcp_no_metrics_save=1
  71. net.ipv4.tcp_ecn=0
  72. net.ipv4.tcp_frto=0
  73. net.ipv4.tcp_mtu_probing=0
  74. net.ipv4.tcp_rfc1337=0
  75. net.ipv4.tcp_sack=1
  76. net.ipv4.tcp_fack=1
  77. net.ipv4.tcp_window_scaling=1
  78. net.ipv4.tcp_adv_win_scale=1
  79. net.ipv4.tcp_moderate_rcvbuf=1
  80. net.core.rmem_max=33554432
  81. net.core.wmem_max=33554432
  82. net.ipv4.tcp_rmem=65536 1048576 33554432
  83. net.ipv4.tcp_wmem=65536 1048576 33554432
  84. net.ipv4.udp_rmem_min=8192
  85. net.ipv4.udp_wmem_min=8192
  86. net.ipv4.tcp_mem=262144 1048576 4194304
  87. net.ipv4.udp_mem=262144 524288 1048576
  88. # BBR
  89. net.ipv4.tcp_congestion_control=bbrplus
  90. net.core.default_qdisc=fq
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/892426
推荐阅读
相关标签
  

闽ICP备14008679号