Deploy Google BBR on CentOS 7

部署BBR算法
本文介绍如何在CentOS 7上部署BBR(Bottleneck Bandwidth and RTT)拥塞控制算法,通过升级内核并配置sysctl参数实现网络性能提升。

BBR (Bottleneck Bandwidth and RTT) is a new congestion control algorithm which is contributed to the Linux kernel TCP stack by Google. With BBR in place, a Linux server can get significantly increased throughput and reduced latency for connections. Besides, it's easy to deploy BBR because this algorithm requires only updates on the sender side, not in the network or on the receiver side.

In this article, I will show you how to deploy BBR on a CentOS 7 server instance.

Step 1: Upgrade the kernel using the ELRepo RPM repository

In order to use BBR, you need to upgrade the kernel of your CentOS 7 machine to atest kernel(≥4.9.0). You can easily get that done using the ELRepo RPM repository

  • Before the upgrade, you can take a look at the current kernel:

    uname -r
    复制代码

    This command should output a string which resembles:

    kernel-3.10.0-862.el7.x86_64

    As you see, the current kernel is 3.10.0.

  • Install the ELRepo repo

    rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
    rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
    复制代码
  • Install the latest kernel using the ELRepo repo:

    yum --enablerepo=elrepo-kernel install kernel-ml -y
    复制代码
  • Confirm the result

    rpm -qa | grep kernel
    复制代码

    If the installation is successful, you should see kernel-ml-4.17.0-1.el7.elrepo.x86_64 among the output list:

    kernel-3.10.0-862.el7.x86_64
    kernel-ml-4.17.0-1.el7.elrepo.x86_64
    kernel-tools-libs-3.10.0-862.3.2.el7.x86_64
    kernel-3.10.0-862.3.2.el7.x86_64
    kernel-tools-3.10.0-862.3.2.el7.x86_64

    Now, you need to enable the 4.17.0 kernel by setting up the default grub2 boot entry.

  • Show all entries in the grub2 menu

    awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
    复制代码

    The result should resemble:

    0 : CentOS Linux 7 Rescue 73af6d633b0a40ceab1e8326f2dd1726 (4.17.0-1.el7.elrepo.x86_64)
    1 : CentOS Linux (4.17.0-1.el7.elrepo.x86_64) 7 (Core)
    2 : CentOS Linux (3.10.0-862.3.2.el7.x86_64) 7 (Core)
    3 : CentOS Linux (3.10.0-862.el7.x86_64) 7 (Core)
    4 : CentOS Linux (0-rescue-f61a3aaf38e24555b5249a9aa4805773) 7 (Core)

    Since the line count starts at 0 and the 4.17.0 kernel entry is on the second line, set the default boot entry as 1:

    grub2-set-default 1
    复制代码

    Reboot the system:

    reboot
    复制代码

    You should see the result as below:

    4.17.0-1.el7.elrepo.x86_64

Step 2: Enable BBR

  • In order to enable the BBR algorithm, you need to modify the sysctl configuration as follows:

    echo 'net.core.default_qdisc=fq' | sudo tee -a /etc/sysctl.conf
    echo 'net.ipv4.tcp_congestion_control=bbr' | sudo tee -a /etc/sysctl.conf
    sudo sysctl -p
    复制代码

    Now, you can use the following commands to confirm that BBR is enabled:

    sysctl net.ipv4.tcp_available_congestion_control
    复制代码

    The output should resemble:

    net.ipv4.tcp_available_congestion_control = reno cubic bbr

    Next, verify with:

    sysctl -n net.ipv4.tcp_congestion_control
    复制代码

    The output should be:

    bbr

    Finally, check that the kernel module was loaded:

    lsmod | grep bbr
    复制代码

    The output will be similar to:

    tcp_bbr 20480 17

Step 3: Test the network performance enhancement.(optional)

In order to test BBR's network performance enhancement, you can create a file in the web server directory for download, and then test the download speed from a web browser on your desktop machine.

yum install httpd -y
systemctl start httpd.service
firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --reload
cd /var/www/html
dd if=/dev/zero of=500mb.zip bs=1024k count=500
复制代码

Finally, visit the URL http://[your-server-IP]/500mb.zip from a web browser on your desktop computer, and then evaluate download speed.

转载于:https://juejin.im/post/5b193aa7e51d4506a81b5e61

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值