以下步骤涉及到编辑文件,这个需要vim或者其他的编辑工具,如果不会使用就看这个教程
其他的优化方案:https://doub.io/ss-jc26/#三、优化Shadowsocks
不会链接VPS的,你需要看着个:Linux SSH链接工具 Putty 新手详细使用教程
提高文件最大并发数
为了处理数千个并发的TCP连接,我们应该增加同时打开文件最大并发数的限制。
添加两行文本到limits.conf
# 下面全部内容请一起复制,一起粘贴,一起执行! echo '* soft nofile 51200 * hard nofile 51200' >> /etc/security/limits.conf
VPS提示示例:
# 示例 # [email protected]:~# echo '* soft nofile 51200 > * hard nofile 51200' >> /etc/security/limits.conf [email protected]:~# ulimit -n 51200 # 并不会有什么提示 # # 示例 #
然后,设置 ulimit 即可。
ulimit -n 51200
调整内核参数+开启高级算法 hybla
注意:此步骤不适用于OpenVZ或低版本内核,否则在执行最后一个步骤 sysctl -p 的时候会大量报错,如果没报错说明内核支持高级算法hybla等参数调整。
注意:该算法和 BBR 同属于集成于内核中的模块,当两者同时开启后,BBR 优先级最高。所以开启 BBR 后再开这个没用。
添加一些参数到/etc/sysctl.conf
# 下面全部内容请一起复制,一起粘贴,一起执行! echo 'fs.file-max = 51200 net.core.rmem_max = 67108864 net.core.wmem_max = 67108864 net.core.netdev_max_backlog = 250000 net.core.somaxconn = 4096 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 0 net.ipv4.tcp_fin_timeout = 30 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_fastopen = 3 net.ipv4.tcp_mem = 25600 51200 102400 net.ipv4.tcp_rmem = 4096 87380 67108864 net.ipv4.tcp_wmem = 4096 65536 67108864 net.ipv4.tcp_mtu_probing = 1 net.ipv4.tcp_congestion_control = hybla' >> /etc/sysctl.conf
VPS提示示例:
# 示例 # [email protected]:~# echo 'fs.file-max = 51200 > net.core.rmem_max = 67108864 > net.core.wmem_max = 67108864 > net.core.netdev_max_backlog = 250000 > net.core.somaxconn = 4096 > net.ipv4.tcp_syncookies = 1 > net.ipv4.tcp_tw_reuse = 1 > net.ipv4.tcp_tw_recycle = 0 > net.ipv4.tcp_fin_timeout = 30 > 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_fastopen = 3 > net.ipv4.tcp_mem = 25600 51200 102400 > net.ipv4.tcp_rmem = 4096 87380 67108864 > net.ipv4.tcp_wmem = 4096 65536 67108864 > net.ipv4.tcp_mtu_probing = 1 > net.ipv4.tcp_congestion_control = hybla' >> /etc/sysctl.conf # 示例 #
然后记得执行 sysctl -p
以重新加载配置。
VPS提示示例:
# 示例 # [email protected]:~# sysctl -p fs.file-max = 51200 net.core.rmem_max = 67108864 net.core.wmem_max = 67108864 net.core.netdev_max_backlog = 250000 net.core.somaxconn = 4096 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 0 net.ipv4.tcp_fin_timeout = 30 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_fastopen = 3 net.ipv4.tcp_mem = 25600 51200 102400 net.ipv4.tcp_rmem = 4096 87380 67108864 net.ipv4.tcp_wmem = 4096 65536 67108864 net.ipv4.tcp_mtu_probing = 1 net.ipv4.tcp_congestion_control = hybla # 示例 #
如果提示类似于这样的信息,那么说明你的内核不支持提示错误的那个功能或命令。
sysctl: cannot stat /proc/sys/net/ipv4/xxxxx: No such file or directory
参考资料:https://shadowsocks.org/en/config/advanced.html
其他的优化方案:https://doub.io/ss-jc26/#三、优化Shadowsocks
转载请超链接注明:月下博客 » Linux 提高文件并发数、开启高级算法hybla 以优化Shadowsocks
责任声明:本站一切资源仅用作交流学习,请勿用作商业或违法行为!如造成任何后果,本站概不负责!