linux sysctl 网络性能优化
问题:http-client Get http://localhost:8080 dial tcp localhost:8080 cannot assign requested address
解决方案:
修改/etc/sysctl.conf的值,向里面添加如下内容:
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_tw_buckets = 180000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_keepalive_time = 1800
net.ipv4.tcp_fin_timeout = 30
net.core.netdev_max_backlog =8096
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_rmem = 16384 174760 349520
net.ipv4.tcp_wmem = 16384 131072 262144
net.ipv4.tcp_mem = 262144 524288 1048576
然后再用命令sudo sysctl -p 刷新配置文件即可.
其中tcp_syncookies表示net.ipv4.tcp_max_tw_buckets,net.ipv4.tcp_tw_reuse ,以及net.ipv4.tcp_tw_recycle 与timewait网络连接等待数有关,必须优化,其他可选择优化.
参考:http://blog.csdn.net/unix21/article/details/8743537
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步