shadowsocks服务端优化设置

推特上两位推友@m0d8ye(libev版的作者)和@_zzzh提供的shadowsocks服务端网络优化方案,基本原理相似,都是通过修改sysctl.conf相关参数实施的,目标是在高并发、高延迟的网络环境下提高shadowsocks的响应和链接速度。
@m0d8ye提供的sysctl.conf修改参数:
net.core.wmem_max = 12582912
net.core.rmem_max = 12582912
net.ipv4.tcp_rmem = 10240 87380 12582912
net.ipv4.tcp_wmem = 10240 87380 12582912
net.ipv4.ip_local_port_range = 18000 65535
net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_max_syn_backlog = 3240000
net.core.somaxconn = 3240000
net.ipv4.tcp_max_tw_buckets = 1440000
net.ipv4.tcp_congestion_control = cubic
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_tw_recycle = 1
@_zzzh(原文:高流量大并发linux Tcp 性能调优)提供的sysctl.conf修改参数:
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
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.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
net.core.netdev_max_backlog = 250000
net.ipv4.tcp_mtu_probing=1
net.ipv4.tcp_congestion_control=hybla
sysctl net.ipv4.tcp_available_congestion_control  /sbin/modprobe tcp_hybla  nano /etc/sysctl.conf  sysctl -p
由于本人的shadowsocks为自用,高并发的多人使用效果没做具体测试,效果未知。但按方案二将拥塞算法由cubic改为hybla模式后,在晚高峰时段观看视频的速度确实有显著改善,推荐大家尝试。

没有评论: