Quantcast
Channel: CodeSection,代码区,Linux操作系统:Ubuntu_Centos_Debian - CodeSec
Viewing all articles
Browse latest Browse all 11063

BBR,继锐速之后的新秀

$
0
0
引子

最近BBR炒得沸沸扬扬,号称是锐速之后的在单边加速上的新秀。

它是linux kernel 4.9引进的拥塞控制算法。由于本人不是研究该领域的,根据 知乎大牛的说法 :

TCP BBR 致力于解决两个问题: 在有一定丢包率的网络链路上充分利用带宽。 降低网络链路上的 buffer 占用率,从而降低延迟。

感兴趣的还可以读下paper: BBR: Congestion-Based Congestion Control 。

任何有可能提高FQ速度的方法都值得一试,于是挑了一个下午开始折腾。

启用BBR

修改配置文件

$ sudo vim /etc/sysctl.d/local.conf

加入以下内容(如已有,则修改)

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

保存使其生效

$ sudo sysctl -p

重启

$ sudo reboot

确认是否成功启用

$ sysctl net.ipv4.tcp_available_congestion_control net.ipv4.tcp_available_congestion_control = bbr cubic reno $ lsmod | grep bbr tcp_bbr 20480 15

不幸的是即使更换了linode提供的最新kernel(4.9.0-x86_64-linode79),BBR依然无法启用。因此需要手动安装最新版kernel。

安装kernel 通用步骤

下载内核

在 http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9/ 找到最新版kernel,下载下来

$ wget -O linux-image-4.9.0-amd64.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9/linux-image-4.9.0-040900-generic_4.9.0-040900.201612111631_amd64.deb

安装内核

$ sudo dpkg -i linux-image-4.9.0-amd64.deb

接下来区分KVM还是XEN,亲测XEN按照KVM的流程来做是无法在linode的kernel项中找到grub 2选项的。

KVM

安装grub2

$ sudo apt-get install linux-image-virtual grub2

确认内核安装成功

$ ls /boot/vmlinuz* | grep 4.9 /boot/4.9.0-040900-generic

编辑GRUB文件

$ sudo vim /etc/default/grub

在最下方加入以下配置

GRUB_TIMEOUT=10 GRUB_DISABLE_LINUX_UUID=true GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0,19200n8" GRUB_SERIAL_COMMAND="serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1" GRUB_TERMINAL="serial console"

同时将GRUB_HIDDEN开头的注释掉。

更新GRUB

$ sudo update-grub

显示在最顶端的kernel就是即将启动的kernel。如果没显示在最顶端,就在它之上的kernel删掉

$ sudo apt-get purge

引导

进入linode的dashboard,选中当前的Configuration Profiles点击edit,在kernel选项处选择Grub2。

重启VPS

$ sudo reboot XEN

安装grub

$ sudo apt-get purge grub2 grub-pc $ sudo apt-get install linux-image-virtual grub

确认内核安装成功

$ ls /boot/vmlinuz* | grep 4.9 /boot/4.9.0-040900-generic

编辑GRUB文件

首先通过update-grub生成menu.lst,编辑之:

$ sudo vim /etc/default/grub

修改以下两项属性:

# kopt=root=/dev/xvda console=hvc0 ro quiet # groot=(hd0)

更新GRUB

$ sudo update-grub

验证

确认/etc/init/hvc0.conf内容

# cat /etc/init/hvc0.conf # hvc0 - getty # # This service maintains a getty on hvc0 from the point the system is # started until it is shut down again. start on stopped rc RUNLEVEL=[2345] stop on runlevel [!2345] respawn exec /sbin/getty -8 38400 hvc0

引导

进入linode的dashboard,选中当前的Configuration Profiles点击edit,在kernel选项处选择pv-grub-x86_64。 确保root device为xvda,Filesystem/Boot Helpers-Distro Helper为No。

重启VPS

$ sudo reboot 测试

在翻阅文章的过程中,我也看到了对BBR持负面观点的 文章 ,作者认为BBR不是银弹,它的效果取决于具体的网络状况。因此对于我自己常用的网络环境,我在油管随便找了个4K视频,在多时段进行了简单的测试。这也是本文在写好后拖了十几天才发出来的原因。

视频地址:

https://www.youtube.com/watch?v=GxvgWUrJT3I

配置

Linode Tokyo 1

锐速 kernel 3.18.5 linode 52

bbr kernel 4.9.0-040900

清晨

锐速


BBR,继锐速之后的新秀
BBR,继锐速之后的新秀

BBR


BBR,继锐速之后的新秀
BBR,继锐速之后的新秀
普通时段

锐速


BBR,继锐速之后的新秀
BBR,继锐速之后的新秀

BBR


BBR,继锐速之后的新秀
BBR,继锐速之后的新秀
某恶劣网络

锐速


BBR,继锐速之后的新秀
BBR,继锐速之后的新秀

BBR


BBR,继锐速之后的新秀
BBR,继锐速之后的新秀
总结

根据以上测试,在我的网络环境下,bbr比起锐速有一点点提升。同时在使用过程中可以感觉到,bbr在提速上表现更好,即能够更快地达到当前网络速度的“上限”,即使遇到速度突然下滑(目测丢包了)的情况,也能在几秒内重新爬升到“上限”。因此,对于我来说bbr是一个更好的选择,比起锐速,它免费,可靠。同时脱离了3.18.5这个老kernel的限制,能够使用新kernel的特性。至此,总算跟锐速这个让人又爱又恨的家伙say goodbye了。

参考

https://www.zhihu.com/question/53559433

http://madlax.pw/2016/06/15/57.html

http://madlax.pw/2016/12/03/103.html


Viewing all articles
Browse latest Browse all 11063

Trending Articles