Linux 开启 TCP BBR 提高网络速度


TCP BBR (TCP Bottleneck Bandwidth and Round-trip propagation time) 是 Google 开发的 TCP 壅塞控制算法, 可以提高网络连线的传输量。Google 在 google.com 及 Youtube 上使用 TCP BBR, 在全球的网络吞吐量提升了 4%, 而有些个别国家更提升超过 14%.

TCP BBR 已经整合到 Kernel 4.9 或以上的版本, 如果核心版本已经在 4.9 或以上, 开启十分简单。要检视目前使用的 kernel 版本, 执行 uname 查看:

/linux/uname

  • # uname -sr
    Linux 4.18.16-x86_64-linode118

我的 Linode VPS 默认已经使用 4.18 kernel, 可以使用 TCP BBR.

Ubuntu 18.04 已经可以使用, 如果是 CentOS 7, 可以参考以下文章升级 kernel 到 4.20.x:

CentOS 7 升级核心 Kernel 4.20.x

执行 lsmod 指令, 检视是否已经开启 TCP BBR:

/linux/lsmod

  • # lsmod | grep bbr

如果没有输出 tcp_bbr, 执行以下指令开启 TCP BBR:

/linux/enable-tcp-bbr

  • # modprobe tcp_bbr
    # echo “tcp_bbr” >> /etc/modules-load.d/modules.conf
    # echo “net.core.default_qdisc=fq” >> /etc/sysctl.conf
    # echo “net.ipv4.tcp_congestion_control=bbr” >> /etc/sysctl.conf

已经将新设定写入 /etc/sysctl.conf 档案, 下次开启会自动开启 TCP BBR, 要 TCP BBR 的设定立即生效, 可以执行 sysctl -p 指令:

/linux/sysctl

  • # sysctl -p
    net.core.default_qdisc = fq
    net.ipv4.tcp_congestion_control = bbr

而且只要核心版本是 4.9 或以上, 不需要变更其他系统及网络设定, 便可以开启 TCP BBR 提升网络速度, 十分值得使用。

Leave a Reply