avatar

ShīnChvën ✨

Effective Accelerationism

Powered by Druid

搬瓦工火力全开

Fri Nov 30 2018

搬瓦工KiwiVM管理后台取消了一键黑科技

入了一个年付27.6刀的搬瓦工黑五特别折扣版VPS(2018 Black Friday Special V3 CN2),登录以后发现不再有一键黑科技,原因是搬瓦工自己推出了专门的黑科技上网服务。原先购买的版本,还可以在KiwiVM Control Panel中继续使用一键黑科技。既然不再有一键黑科技,那就只能自己搭建了。

自己搭建的版本与一键黑科技安装的版本性能区别很大

由于我现在着迷于docker,于是使用了热门的Docker image来搭建黑科技。我参照README.MD编写好了shell脚本和docker-compose,非常轻松地就拉起了黑科技的container。正在沾沾自喜的时候,却发现自己搭建的版本和KiwiVM管理后台中的一键版有非常大的性能区别,从原先的4K无压力到现在480P都够呛。

这其中到底有怎样的魔法?

我开始排查是哪里出了问题

我怀疑一共有以下几种可能性:

  • CN2机房线路问题;
  • Docker image版的问题;
  • 安装程序版本;
  • OS版本;

我回到老版本的VPS中去验证,重装了OS,重装了多个版本的黑科技以及网上流传的一键脚本,还是不能实现跟KiwiVM管理面板中一键安装版同样的性能,这让我非常苦恼。

突然我开始回想起被官方文档支配的恐惧

在官网文档中的高级配置章节提到需要对VPS进行两处优化:

文件 说明
/etc/security/limits.conf 增加打开文件描述符的最大数量
/etc/sysctl.conf 调整内核参数

limits.conf

root soft nofile 4096
root hard nofile 10000

如果使用 docker 部署,可以修改 docker 的配置 /etc/docker/daemon.json,增加 default-ulimits 配置项:

{
  "default-ulimits": {
    "nofile": {
      "Name": "nofile",
      "Hard": 10000,
      "Soft": 4096
    }
  }
}

sysctl.conf

# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
# sysctl.conf(5) for more details.
#
# Use '/sbin/sysctl -a' to list all possible parameters.

# Controls IP packet forwarding
net.ipv4.ip_forward = 0

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1

# Controls the default maxmimum size of a mesage queue
kernel.msgmnb = 65536

# Controls the maximum size of a message, in bytes
kernel.msgmax = 65536

# Controls the maximum shared segment size, in bytes
kernel.shmmax = 4294967295

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 268435456

net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr

net.ipv4.neigh.default.base_reachable_time_ms = 600000
net.ipv4.neigh.default.mcast_solicit = 20
net.ipv4.neigh.default.retrans_time_ms = 250

这个配置我之前照着在DigitalOcean的VPS里试过,效果不好,这次我也在搬瓦工上试了,效果仍然不理想。我顺着这个思路往下找,惊讶地发现用过KiwiVM管理面板中一键安装黑科技的VPS的内核参数配置与官方文档中有不少出入!

原来你使用了这样的魔法!

我复制来一份放到自己搭建的版本里,魔法终于施展成功!火力全开!

connection-speed-full-power-activated.jpg