Shadowsocks优化方案

Shadowsocks优化方案:

1. 搬瓦工优化方案:
rm -f /sbin/modprobe
ln -s /bin/true /sbin/modprobe
rm -f /sbin/sysctl
ln -s /bin/true /sbin/sysctl
vi /etc/sysctl.conf

#增加以下内容
fs.file-max = 51200
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
# increase TCP max buffer size settable using setsockopt()
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
# increase Linux autotuning TCP buffer limit
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
# increase the length of the processor input queue
net.core.netdev_max_backlog = 250000
# recommended for hosts with jumbo frames enabled
net.ipv4.tcp_mtu_probing=1
#增加以上内容

sysctl -p
reboot

#重启回来继续执行以下命令
apt-get install libnet1
apt-get install libpcap0.8
apt-get install libnet1-dev
apt-get install libpcap0.8-dev
wget https://net-speeder.googlecode.com/files/net_speeder-v0.1.tar.gz
tar zxvf net_speeder-v0.1.tar.gz
sh ./net_speeder/build.sh -DCOOKED
./net_speeder/net_speeder venet0 “tcp” > netlog &

注意!

关于apt-get install libnet1报错..
先执行一下
apt-get update
apt-get upgrade
更新完成再安装libnet1试试看..
我在搬瓦工上实测不会报错..
还有..如果是centos的话..是不能这样安装的..

安装Net_speeder
由于TCP的特性导致,每个包发一次,容易掉包。干脆就一个包发两次,有效降低掉包率。
Net_speeder的项目地址

debian/ubuntu安装libnet:apt-get install libnet1
安装libpcap: apt-get install libpcap0.8
编译需要安装libnet和libpcap对应的dev包
debian/ubuntu安装libnet-dev:apt-get install libnet1-dev
安装libpcap-dev: apt-get install libpcap0.8-dev

centos安装:
下载epel:https://fedoraproject.org/wiki/EPEL/zh-cn
例:CentOS6 64位:wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
如果是centos5,则在epel/5/下
然后安装epel:rpm -ivh epel-release-X-Y.noarch.rpm
然后即可使用yum安装:yum install libnet libpcap libnet-devel libpcap-devel
下载net-speeder:wget https://net-speeder.googlecode.com/files/net_speeder-v0.1.tar.gz
解压缩:tar -zxvf net_speeder-v0.1.tar.gz
使用方法(需要root权限启动):
参数:./net_speeder 网卡名 加速规则(bpf规则)
最简单用法: # ./net_speeder venet0 “ip” 加速所有ip协议数据

2.Do优化方案:
vi /etc/sysctl.d/local.conf

#增加以下内容
fs.file-max = 51200

net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.core.rmem_default = 65536
net.core.wmem_default = 65536
net.core.netdev_max_backlog = 4096
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 = 4096
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
net.ipv4.tcp_mtu_probing = 1

# for high-latency network
net.ipv4.tcp_congestion_control = htcp #如果是do主机+debian7..可以使用hybla参数..其他vps主机如使用htcp报错请更换高版本内核或使用cubic参数

# for low-latency network, use cubic instead
# net.ipv4.tcp_congestion_control = cubic
#增加以上内容

sysctl –system
ulimit -n 51200
reboot

锐速(可选..且只能安装在DO主机上..搬瓦工不支持):

首先去 http://www.serverspeeder.com/  免费注册

wget http://dl.serverspeeder.com/d/ls/serverSpeederInstaller.tar.gz
tar xzvf serverSpeederInstaller.tar.gz
bash serverSpeederInstaller.sh

vi /serverspeeder/etc/config
rsc=”1″
maxmode=”1″
advinacc=”1″

./serverspeeder/bin/serverSpeeder.sh restart

本人不答疑..因为本人很菜..这些内容都是网上搜集到的..

Share

Leave a Reply

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

Post comment