{"action":"created","issue":{"url":"https://api.github.com/repos/phuslu/goproxy/issues/186","repository_url":"https://api.github.com/repos/phuslu/goproxy","labels_url":"https://api.github.com/repos/phuslu/goproxy/issues/186/labels{/name}","comments_url":"https://api.github.com/repos/phuslu/goproxy/issues/186/comments","events_url":"https://api.github.com/repos/phuslu/goproxy/issues/186/events","html_url":"https://github.com/phuslu/goproxy/issues/186","id":105535954,"number":186,"title":"[原创]服务器参数优化，让你的搬瓦工也能看高清720P","user":{"login":"cmdlet1","id":14194638,"avatar_url":"https://avatars.githubusercontent.com/u/14194638?v=3","gravatar_id":"","url":"https://api.github.com/users/cmdlet1","html_url":"https://github.com/cmdlet1","followers_url":"https://api.github.com/users/cmdlet1/followers","following_url":"https://api.github.com/users/cmdlet1/following{/other_user}","gists_url":"https://api.github.com/users/cmdlet1/gists{/gist_id}","starred_url":"https://api.github.com/users/cmdlet1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmdlet1/subscriptions","organizations_url":"https://api.github.com/users/cmdlet1/orgs","repos_url":"https://api.github.com/users/cmdlet1/repos","events_url":"https://api.github.com/users/cmdlet1/events{/privacy}","received_events_url":"https://api.github.com/users/cmdlet1/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":26,"created_at":"2015-09-09T07:30:46Z","updated_at":"2016-09-26T01:07:37Z","closed_at":"2015-09-15T01:27:45Z","body":"本文参考了很多文章后总结出了一套搬瓦工VPS上使用Shadowsocks能够流畅观看视频网站的方法。文章内容是cmdlet总结的，如转载请注明作者和出处。\r\n\r\n我们首先要了解搬瓦工不支持锐速、不支持TCP Fast Open、不支持hybla，加入hybla参数是为了其他服务器也能使用这篇文章的内容，其实那个参数对搬瓦工来说，然 并 卵\r\n\r\n作者本人使用的电信20M光纤宽带，国际网速比较坑爹，优化之后，非高峰时段，Shadowsocks可看720p，高峰时段标清不卡。以下是详细步骤：\r\n搬瓦工可以一键安装Shadowsocks服务器端，这里不多说安装步骤了，网上很多地方也都有。\r\n\r\n<strong>1. 调整搬瓦工Shadowsocks的加密方式</strong>\r\n\r\n加密方式改为CR4-MD5，相对aes-256-cfb来说可能加密方式更弱，但加密速度是后者的好几倍，对于一般用户来说，没有影响但能提高速度。\r\n\r\n服务器端口一定要使用默认的443端口（很重要），具体原因不多讲了，端口特性\r\n\r\n默认是CENTOS 6 X86环境，下面讲讲优化：\r\n\r\n<div><b>2.增加系统文件描述符的最大限数</b></div>\r\n<div></div>\r\n<div>编辑文件 limits.conf</div>\r\n<div></div><br>\r\n<div>vi /etc/security/limits.conf</div><br>\r\n<div></div>\r\n<div>增加以下两行</div>\r\n<div></div><br>\r\n<div>* soft nofile 51200</div>\r\n<div>* hard nofile 51200</div><br>\r\n<div></div>\r\n<div>启动shadowsocks服务器之前，设置以下参数（这一步是Shadowsocks官文上讲的，但实际上上面两步就是执行下面这一步，所以，下面的参数可以跳过了）</div>\r\n<div></div>\r\n<div>ulimit -n 51200</div><br>\r\n<div></div>\r\n<div><b>3. 更新sysctl和modprobe</b></div>（ 非openvz平台跳过这一步，openvz据说改内核参数然并卵，没有副作用，随手做一做吧，下面的也跟着改一改吧）<br>\r\n<div></div>\r\n<div>rm -f /sbin/sysctl</div><br>\r\n<div></div>\r\n<div>ln -s /bin/true /sbin/sysctl</div><br>\r\n<div></div>\r\n<div>rm -f /sbin/modprobe</div><br>\r\n<div></div>\r\n<div>ln -s /bin/true /sbin/modprobe</div><br>\r\n<div></div>\r\n<div><b>4. 修改配置文件 sysctl.conf</b></div><br>\r\n<div></div>\r\n<div>vi /etc/sysctl.conf</div><br>\r\n<div></div>\r\n<div>增加如下内容:</div><br>\r\n<div></div>\r\n<div>fs.file-max = 51200</div>\r\n<div>net.ipv4.conf.lo.accept_redirects=0</div>\r\n<div>net.ipv4.conf.all.accept_redirects=0</div>\r\n<div>net.ipv4.conf.eth0.accept_redirects=0</div>\r\n<div>net.ipv4.conf.default.accept_redirects=0</div>\r\n<div>net.ipv4.ip_local_port_range = 10000 65000</div>\r\n<div>net.ipv4.tcp_congestion_control = hybla</div>\r\n<div>net.ipv4.tcp_fin_timeout = 30</div>\r\n<div>net.ipv4.tcp_fastopen = 3</div>\r\n<div>net.ipv4.tcp_keepalive_time = 1200</div>\r\n<div>net.ipv4.tcp_rmem  = 32768 436600 873200</div>\r\n<div>net.ipv4.tcp_syncookies = 1</div>\r\n<div>net.ipv4.tcp_synack_retries = 2</div>\r\n<div>net.ipv4.tcp_syn_retries = 2</div>\r\n<div>net.ipv4.tcp_tw_reuse = 1</div>\r\n<div>net.ipv4.tcp_tw_recycle = 0</div>\r\n<div>net.ipv4.tcp_timestsmps = 0</div>\r\n<div>net.ipv4.tcp_tw_reuse = 1</div>\r\n<div>net.ipv4.tcp_max_tw_buckets = 9000</div>\r\n<div>net.ipv4.tcp_max_syn_backlog = 65536</div>\r\n<div>net.ipv4.tcp_mem = 94500000 91500000 92700000</div>\r\n<div>net.ipv4.tcp_max_orphans = 3276800</div>\r\n<div>net.ipv4.tcp_mtu_probing = 1</div>\r\n<div>net.ipv4.tcp_wmem = 8192 436600 873200</div>\r\n<div>net.core.netdev_max_backlog = 250000</div>\r\n<div>net.core.somaxconn = 32768</div>\r\n<div>net.core.wmem_default = 8388608</div>\r\n<div>net.core.rmem_default = 8388608</div>\r\n<div>net.core.rmem_max = 67108864</div>\r\n<div>net.core.wmem_max = 67108864</div><br>\r\n<div></div>\r\n<div>执行生成</div><br>\r\n<div></div>\r\n<div>sysctl -p</div><br>\r\n<div></div>\r\n<div><b>5. 安装net-speeder</b></div><br>\r\n<div></div>\r\n<div>分别执行以下命令：</div><br>\r\n<div></div>\r\n<div>wget --no-check-certificate https://gist<wbr />.github.com/<wbr />LazyZhu/dc3f<wbr />2f84c336a08f<wbr />d6a5/raw/d8a<wbr />a4bcf955409e<wbr />28a262ccf529<wbr />21a65fe49da9<wbr />9/net_speede<wbr />r_lazyinstal<wbr />l.sh</div>\r\n<div></div><br>\r\n<div>sh net_speeder_lazyinstall.sh</div><br>\r\n<div></div>\r\n<div>加入开机启动</div><br>\r\n<div></div>\r\n<div>echo 'nohup /usr/local/net_speeder/net_speeder venet0 \"ip\" &gt;/dev/null 2&gt;&amp;1 &amp;' &gt;&gt; /etc/rc.local</div><br>\r\n<div></div>\r\n<div><b>6. 重启VPS</b></div><br>\r\n<div></div>\r\n<div>reboot</div>\r\n<div></div>\r\n<div></div>\r\n<div>以上步骤执行完成之后速度效果如下：</div>\r\n<div> <img  src=\"https://cloud.githubusercontent.com/assets/14194638/9777924/7100252a-579c-11e5-9999-bd2e4bdd8b2c.png\"   /> </div>\r\n\r\n\r\n<div></div>\r\n<div>文件下载实时速度：</div>\r\n<div><img  src=\"https://cloud.githubusercontent.com/assets/14194638/9777957/d4b4853e-579c-11e5-9cfa-a9257a58ae05.png\"   /> </div>\r\n\r\n\r\n<div></div>\r\n<div>\r\n\r\n<hr />\r\n\r\n</div>\r\n<div>\r\n\r\n<strong>参考文献：</strong><br>\r\n\r\nShadowsocks官方服务器优化之南<br>\r\n\r\nhttps://github.com/shadowsocks/shadowsocks/wiki/Optimizing-Shadowsocks<br>\r\n\r\nshao.bing的博文<br>\r\n\r\nhttp://blog.csdn.net/shaobingj126/article/details/8549494<br>\r\n\r\nnet-speeder安装指南<br>\r\n\r\nhttps://code.google.com/p/net-speeder<br>\r\n\r\nLazyZhu的懒人脚本<br>\r\n\r\nhttps://github.com/LazyZhu<br>\r\n</div>"},"comment":{"url":"https://api.github.com/repos/phuslu/goproxy/issues/comments/249459290","html_url":"https://github.com/phuslu/goproxy/issues/186#issuecomment-249459290","issue_url":"https://api.github.com/repos/phuslu/goproxy/issues/186","id":249459290,"user":{"login":"tianlichunhong","id":13270039,"avatar_url":"https://avatars.githubusercontent.com/u/13270039?v=3","gravatar_id":"","url":"https://api.github.com/users/tianlichunhong","html_url":"https://github.com/tianlichunhong","followers_url":"https://api.github.com/users/tianlichunhong/followers","following_url":"https://api.github.com/users/tianlichunhong/following{/other_user}","gists_url":"https://api.github.com/users/tianlichunhong/gists{/gist_id}","starred_url":"https://api.github.com/users/tianlichunhong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tianlichunhong/subscriptions","organizations_url":"https://api.github.com/users/tianlichunhong/orgs","repos_url":"https://api.github.com/users/tianlichunhong/repos","events_url":"https://api.github.com/users/tianlichunhong/events{/privacy}","received_events_url":"https://api.github.com/users/tianlichunhong/received_events","type":"User","site_admin":false},"created_at":"2016-09-26T01:07:37Z","updated_at":"2016-09-26T01:07:37Z","body":"据说finalspeed耗资源厉害，新出的kcptun据说不错。"}}
{"actor":{"display_login":"tianlichunhong"}}