[R]Improve the performance of the Shadowsocks on OpenVZ Virtual Machines

1.Adjust Shadowsocks Encrypt Method

If you are using AES-256-CFB encrypt, please change it to RC4-MD5 encrypt. It would be faster to encrypt, but at the same time, of course, less strength in security.

2.增加系统文件描述符上限



vi /etc/security/limits.conf
* soft nofile 51200
* hard nofile 51200

(这一步等同于在启动时执行ulimit -n 51200

3.安装net-speeder

wget --no-check-certificate https://gist.github.com/LazyZhu/dc3f2f84c336a08fd6a5/raw/d8aa4bcf955409e28a262ccf52921a65fe49da99/net_speeder_lazyinstall.sh

sh net_speeder_lazyinstall.sh

别忘了把 nohup /usr/local/net_speeder/net_speeder venet0 [server_ip]加入开机启动.(如:nohup /usr/local/net_speeder/net_speeder venet0 1.2.3.4)

接下来的操作就我个人测试感觉没有效果,当然你也可以相信下面的操作有用,死马当作活马医

4.更新sysctl和modprobe(不推荐)

rm -f /sbin/sysctl
ln -s /bin/true /sbin/sysctl

rm -f /sbin/modprobe
ln -s /bin/true /sbin/modprobe

 5. 修改配置文件 sysctl.conf(不推荐)

vi /etc/sysctl.conf

添加:

fs.file-max = 51200
net.ipv4.conf.lo.accept_redirects=0
net.ipv4.conf.all.accept_redirects=0
net.ipv4.conf.eth0.accept_redirects=0
net.ipv4.conf.default.accept_redirects=0
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_congestion_control = hybla
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_rmem = 32768 436600 873200
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_timestsmps = 0
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_max_tw_buckets = 9000
net.ipv4.tcp_max_syn_backlog = 65536
net.ipv4.tcp_mem = 94500000 91500000 92700000
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_wmem = 8192 436600 873200
net.core.netdev_max_backlog = 250000
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864

使修改生效

sysctl -p


Refered to: https://github.com/phuslu/goproxy/issues/186

6 comments

  1. you are in reality a excellent webmaster. The website loading pace is incredible. It seems that you’re doing any distinctive trick. Also, The contents are masterpiece. you have performed a wonderful task on this subject!

Leave a Reply

Your email address will not be published. Required fields are marked *