逗比云还是逃不过被墙的命运,既然如此那以后逗比云也就一直用被墙的旧域名 [softsmirror.cf] 算了。
投稿文章 | 广告合作 | Telegram 群组 / 公告频道 / 使用教程
广告

Linux 提高文件并发数、开启高级算法hybla 以优化Shadowsocks

Linux教程 Toyo 33评论
广告
本文最后更新于 2018年1月11日 21:05 可能会因为没有更新而失效。如已失效或需要修正,请留言!

以下步骤涉及到编辑文件,这个需要vim或者其他的编辑工具,如果不会使用就看这个教程

其他的优化方案:https://doub.io/ss-jc26/#三、优化Shadowsocks


不会链接VPS的,你需要看着个:Linux SSH链接工具 Putty 新手详细使用教程

提高文件最大并发数

为了处理数千个并发的TCP连接,我们应该增加同时打开文件最大并发数的限制。

添加两行文本到limits.conf

  1. # 下面全部内容请一起复制,一起粘贴,一起执行!
  2.  
  3. echo '* soft nofile 51200
  4. * hard nofile 51200' >> /etc/security/limits.conf

VPS提示示例:

  1. # 示例 #
  2. root@debian:~# echo '* soft nofile 51200
  3. > * hard nofile 51200' >> /etc/security/limits.conf
  4. root@debian:~# ulimit -n 51200
  5. # 并不会有什么提示 #
  6. # 示例 #

然后,设置 ulimit 即可。

  1. ulimit -n 51200

调整内核参数+开启高级算法 hybla

注意:此步骤不适用于OpenVZ或低版本内核,否则在执行最后一个步骤 sysctl -p 的时候会大量报错,如果没报错说明内核支持高级算法hybla等参数调整。

注意:该算法和 BBR 同属于集成于内核中的模块,当两者同时开启后,BBR 优先级最高。所以开启 BBR 后再开这个没用。

添加一些参数到/etc/sysctl.conf

  1. # 下面全部内容请一起复制,一起粘贴,一起执行!
  2.  
  3. echo 'fs.file-max = 51200
  4. net.core.rmem_max = 67108864
  5. net.core.wmem_max = 67108864
  6. net.core.netdev_max_backlog = 250000
  7. net.core.somaxconn = 4096
  8. net.ipv4.tcp_syncookies = 1
  9. net.ipv4.tcp_tw_reuse = 1
  10. net.ipv4.tcp_tw_recycle = 0
  11. net.ipv4.tcp_fin_timeout = 30
  12. net.ipv4.tcp_keepalive_time = 1200
  13. net.ipv4.ip_local_port_range = 10000 65000
  14. net.ipv4.tcp_max_syn_backlog = 8192
  15. net.ipv4.tcp_max_tw_buckets = 5000
  16. net.ipv4.tcp_fastopen = 3
  17. net.ipv4.tcp_mem = 25600 51200 102400
  18. net.ipv4.tcp_rmem = 4096 87380 67108864
  19. net.ipv4.tcp_wmem = 4096 65536 67108864
  20. net.ipv4.tcp_mtu_probing = 1
  21. net.ipv4.tcp_congestion_control = hybla' >> /etc/sysctl.conf

VPS提示示例:

点击展开 查看更多

然后记得执行 sysctl -p 以重新加载配置。

VPS提示示例:

点击展开 查看更多

如果提示类似于这样的信息,那么说明你的内核不支持提示错误的那个功能或命令。

  1. 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
责任声明:本站一切资源仅用作交流学习,请勿用作商业或违法行为!如造成任何后果,本站概不负责!

赞 (16)
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(33)个小伙伴在吐槽
  1. 才发现有个事儿,以前没注意。我先设置好hybla,再去设置bbr。{net.ipv4.tcp_congestion_control = hybla}就这样了,按教程应该是{net.ipv4.tcp_congestion_control = bbr}。这2种技术(我也不知道怎么称呼它俩),都生效了?还是?大佬,靠你了!!
    狒狒2017-12-31 00:42 回复
    • 如果同时开启两个技术,则 BBR优先级最高。
      Toyo2018-01-01 09:48 回复
  2. hybla和BBR可以一起生效吗
    delta432017-12-27 19:11 回复
  3. 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 sysctl: cannot stat /proc/sys/net/ipv4/tcp_fastopen: No such file or directory 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 tcp_fastopen这一行命令报错 ,会影响使用吗?还是就这样就可以 了?
    壮士请留步2017-08-23 09:57 回复
    • 报错说明你的内核不支持 tcp_fastopen ,无视即可。
      Toyo2017-08-23 11:57 回复
  4. 可以和锐速共存不
    chx8182017-06-16 00:28 回复
  5. 这。。。。。又是咋了?
    1. root@chx818 ~]# sysctl -p
    2. net.ipv4.ip_forward = 0
    3. net.ipv4.tcp_syncookies = 1
    4. error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key
    5. error: "net.bridge.bridge-nf-call-iptables" is an unknown key
    6. error: "net.bridge.bridge-nf-call-arptables" is an unknown key
    7. error: permission denied on key 'fs.file-max'
    8. error: permission denied on key 'net.core.rmem_max'
    9. error: permission denied on key 'net.core.wmem_max'
    10. error: permission denied on key 'net.core.netdev_max_backlog'
    11. net.core.somaxconn = 4096
    12. net.ipv4.tcp_syncookies = 1
    13. error: permission denied on key 'net.ipv4.tcp_tw_reuse'
    14. error: permission denied on key 'net.ipv4.tcp_tw_recycle'
    15. error: permission denied on key 'net.ipv4.tcp_fin_timeout'
    16. error: permission denied on key 'net.ipv4.tcp_keepalive_time'
    17. error: permission denied on key 'net.ipv4.ip_local_port_range'
    18. error: permission denied on key 'net.ipv4.tcp_max_syn_backlog'
    19. error: permission denied on key 'net.ipv4.tcp_max_tw_buckets'
    20. error: "net.ipv4.tcp_fastopen" is an unknown key
    21. error: permission denied on key 'net.ipv4.tcp_rmem'
    22. error: permission denied on key 'net.ipv4.tcp_wmem'
    23. error: permission denied on key 'net.ipv4.tcp_mtu_probing'
    24. error: permission denied on key 'fs.file-max'
    25. error: permission denied on key 'net.core.rmem_max'
    26. error: permission denied on key 'net.core.wmem_max'
    27. error: permission denied on key 'net.core.netdev_max_backlog'
    28. net.core.somaxconn = 4096
    29. net.ipv4.tcp_syncookies = 1
    30. error: permission denied on key 'net.ipv4.tcp_tw_reuse'
    31. error: permission denied on key 'net.ipv4.tcp_tw_recycle'
    32. error: permission denied on key 'net.ipv4.tcp_fin_timeout'
    33. error: permission denied on key 'net.ipv4.tcp_keepalive_time'
    34. error: permission denied on key 'net.ipv4.ip_local_port_range'
    35. error: permission denied on key 'net.ipv4.tcp_max_syn_backlog'
    36. error: permission denied on key 'net.ipv4.tcp_max_tw_buckets'
    37. error: "net.ipv4.tcp_fastopen" is an unknown key
    38. error: permission denied on key 'net.ipv4.tcp_mem'
    39. error: permission denied on key 'net.ipv4.tcp_rmem'
    40. error: permission denied on key 'net.ipv4.tcp_wmem'
    41. error: permission denied on key 'net.ipv4.tcp_mtu_probing'
    42. error: permission denied on key 'net.ipv4.tcp_congestion_control'
    chx8182017-06-11 23:00 回复
    • permission denied on key,权限被拒绝,应该是权限方面的问题,不过也没遇到过,是什么虚拟化?是root账号么。
      Toyo2017-06-12 02:00 回复
      • 是root,ovz的
        chx8182017-06-12 18:28 回复
        • OpenVZ大多是版本都很低,不满足第二个优化项目,所以报错正常。
          Toyo2017-06-13 00:33 回复
  6. 这是什么鬼
    1. root@localhost:~# net.core.rmem_max = 67108864
    2. net.core.rmem_max: command not found
    3. root@localhost:~# net.core.wmem_max = 67108864
    4. net.core.wmem_max: command not found
    5. root@localhost:~# net.core.netdev_max_backlog = 250000
    6. net.core.netdev_max_backlog: command not found
    7. root@localhost:~# net.core.somaxconn = 4096
    8. net.core.somaxconn: command not found
    9. root@localhost:~# net.ipv4.tcp_syncookies = 1
    10. net.ipv4.tcp_syncookies: command not found
    11. root@localhost:~# net.ipv4.tcp_tw_reuse = 1
    12. net.ipv4.tcp_tw_reuse: command not found
    13. root@localhost:~# net.ipv4.tcp_tw_recycle = 0
    14. net.ipv4.tcp_tw_recycle: command not found
    15. root@localhost:~# net.ipv4.tcp_fin_timeout = 30
    16. net.ipv4.tcp_fin_timeout: command not found
    17. root@localhost:~# net.ipv4.tcp_keepalive_time = 1200
    18. net.ipv4.tcp_keepalive_time: command not found
    19. root@localhost:~# net.ipv4.ip_local_port_range = 10000 65000
    20. net.ipv4.ip_local_port_range: command not found
    21. root@localhost:~# net.ipv4.tcp_max_syn_backlog = 8192
    22. net.ipv4.tcp_max_syn_backlog: command not found
    23. root@localhost:~# net.ipv4.tcp_max_tw_buckets = 5000
    24. net.ipv4.tcp_max_tw_buckets: command not found
    25. root@localhost:~# net.ipv4.tcp_fastopen = 3
    26. net.ipv4.tcp_fastopen: command not found
    27. root@localhost:~# net.ipv4.tcp_mem = 25600 51200 102400
    28. net.ipv4.tcp_mem: command not found
    29. root@localhost:~# net.ipv4.tcp_rmem = 4096 87380 67108864
    30. net.ipv4.tcp_rmem: command not found
    31. root@localhost:~# net.ipv4.tcp_wmem = 4096 65536 67108864
    32. net.ipv4.tcp_wmem: command not found
    33. root@localhost:~# net.ipv4.tcp_mtu_probing = 1
    34. net.ipv4.tcp_mtu_probing: command not found
    35. root@localhost:~# net.ipv4.tcp_congestion_control = hybla" >> /etc/sysctl.conf
    chx8182017-05-28 03:22 回复
    • 这一整段命令是一起输入的,你提供的信息中少了第一句。
      1. echo 'fs.file-max = 51200
      2. net.core.rmem_max = 67108864
      3. net.core.wmem_max = 67108864
      4. net.core.netdev_max_backlog = 250000
      5. net.core.somaxconn = 4096
      6. net.ipv4.tcp_syncookies = 1
      7. net.ipv4.tcp_tw_reuse = 1
      8. net.ipv4.tcp_tw_recycle = 0
      9. net.ipv4.tcp_fin_timeout = 30
      10. net.ipv4.tcp_keepalive_time = 1200
      11. net.ipv4.ip_local_port_range = 10000 65000
      12. net.ipv4.tcp_max_syn_backlog = 8192
      13. net.ipv4.tcp_max_tw_buckets = 5000
      14. net.ipv4.tcp_fastopen = 3
      15. net.ipv4.tcp_mem = 25600 51200 102400
      16. net.ipv4.tcp_rmem = 4096 87380 67108864
      17. net.ipv4.tcp_wmem = 4096 65536 67108864
      18. net.ipv4.tcp_mtu_probing = 1
      19. net.ipv4.tcp_congestion_control = hybla' >> /etc/sysctl.conf
      Toyo2017-05-28 17:27 回复
  7. 这个是不是有更新了?
    虞山飘渺峰2017-02-22 14:00 回复
  8. 锐速是不是tcp拥塞算法? 如果是的话 假设,假设锐速和bbr能装在同一vps上(我知道内核要求不同 不能同时安装), 系统会优先采用哪种tcp拥塞算法
    南琴浪2017-02-14 02:55 回复
    • 首先锐速和BBR内核要求不一样,无法共存,所以你的假设不成立,无法共存没试过 我怎么知道?
      Toyo2017-02-14 12:13 回复
  9. 逗逼兄,我今天访问你的博客有点延迟,迟缓,还好我是联通 :shock:
    禅猫2017-01-31 23:30 回复
    • 美国的服务器的缺点之一,速度不稳定,毕竟那么远,而且服务器也不是什么亚洲优化之类的线路,美国服务器线路抽风很正常。
      Toyo2017-02-01 00:51 回复
  10. 我的内核是4.93可以用不 :razz: 滑稽233
    禅猫2017-01-31 23:29 回复
    • 没有测试过,应该是支持的,高级算法也是集成在内核里的,需要较新版本(不到4.x.x)的内核,但是是否和BBR互相叠加加速效果并不清楚。
      Toyo2017-02-01 00:50 回复
  11. net.ipv4.tcp_congestion_control = hybla net.ipv4.tcp_congestion_control = bbr 这两个会不会冲突呢?效果会怎样呢?暂时没法测试只能问一下了
    MMY2016-12-22 22:35 回复
    • 没有试过,不清楚
      Toyo2016-12-23 09:27 回复
      • 会冲突,只能二选一,测试发现bbr优于hybla
        fashui012017-11-26 22:28 回复
  12. 请问在服务器端用了你的SSR一键安装脚本后还需要做本文中的这些优化操作吗?还是说这些优化操作只针对SS,对SSR无效?
    MMY2016-11-26 18:45 回复
    • 我的ShadowsocksR一键脚本,只是安装ShadowsocksR和 安装锐速,锐速会自动做好这个文章里的优化,这个文章里的优化和锐速都是不支持OpenVZ。这些优化是针对VPS整体的,VPS相当于虚拟电脑,SS和SSR属于电脑上面的一个软件,你优化了电脑的网速,那你软件的网速同样也优化了。
      Toyo2016-11-26 19:47 回复
  13. 跟LZ一样的,提示 error:permisssion denied....
    hkvps20142016-05-11 09:16 回复
  14. error: "net.ipv4.tcp_fastopen" is an unknown key 这个是什么意思啊??
    fl200022016-04-23 23:13 回复
    • 你的内核并不支持这个
      Toyo2016-04-24 06:31 回复
  15. 不知怎么就进来了,先看看
    171480602015-06-14 18:46 回复

G�|�C���g�|�C���@Amazon Yahoo �y�V

�����z�[���y�[�W �y�V���o�C��[UNLIMIT�����Ȃ�1�~] �C�O�i���q�� �C�O���s�ی��������I