How to Enable Google BBR on CentOS 7

BBR (Bottleneck Bandwidth and Round-trip propagation time) is a new congestion control algorithm developed at Google. Congestion control algorithms running inside every computer, phone, or tablet connected to a network that decides how fast to send data.

Since CentOS 7 ships with the 3.10.x kernel, which does not include BBR by default, we need to upgrade to a newer kernel version on your machine to use BBR.

For this, we 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-2.el7.elrepo.noarch.rpm

Output:

[root@vps ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@vps ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
Retrieving http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
Retrieving http://elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:elrepo-release-7.0-4.el7.elrepo  ################################# [100%]
[root@vps ~]#

To install kernel using the ELRepo repo,

yum --enablerepo=elrepo-kernel install kernel-ml -y

Output:

Dependencies Resolved

================================================================================
 Package        Arch        Version                    Repository          Size
================================================================================
Installing:
 kernel-ml      x86_64      5.12.9-1.el7.elrepo        elrepo-kernel       53 M

Transaction Summary
================================================================================
Install  1 Package
.
.
.
Installed:
  kernel-ml.x86_64 0:5.12.9-1.el7.elrepo

Complete!

Now check the stable kernel installation by using the following command,

rpm -qa | grep kernel

Note: If the installation is successful, you should see kernel-ml-5.xx.xx.elrepo.x86_64 among the output list:

Output:

[root@vps ~]# rpm -qa | grep kernel
kernel-3.10.0-1160.el7.x86_64
kernel-tools-3.10.0-1160.el7.x86_64
kernel-ml-5.12.9-1.el7.elrepo.x86_64
kernel-tools-libs-3.10.0-1160.el7.x86_64
[root@vps ~]#

To Boot into the latest Kernel

Next, you need to boot into the latest kernel by setting it as the default grub2 boot entry.

Command to show all entries in the grub2 menu,

egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'

Output:

[root@vps ~]# egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
CentOS Linux 7 Rescue 13f95ded0c4147935ac6afed832cfb0a (5.12.9-1.el7.elrepo.x86_64)
CentOS Linux (5.12.9-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-dd1973a114f84ea8bbf37b494513d3f7) 7 (Core)

Use the following command to set the default boot entry,

Note: The count starts from 0 and the latest stable kernel is on the second line thus we set it to 1

For example,

[root@vps ~]# egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
CentOS Linux 7 Rescue 13f95ded0c4147935ac6afed832cfb0a (5.12.9-1.el7.elrepo.x86_64)  <-- 0
CentOS Linux (5.12.9-1.el7.elrepo.x86_64) 7 (Core)                                   <-- 1
CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core)                                       <-- 2
CentOS Linux (0-rescue-dd1973a114f84ea8bbf37b494513d3f7) 7 (Core)                    <-- 3
grub2-set-default 1

Reboot the server

shutdown -r now

Once the server is back online, confirm that you are using the correct kerne.

uname -r

Output:

[root@vps ~]# uname -r
5.12.9-1.el7.elrepo.x86_64

Enable Google BBR.

You need to modify systctl as follows to enable the Google BBR algorithm.

echo 'net.core.default_qdisc=fq' | tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_congestion_control=bbr' | tee -a /etc/sysctl.conf

sysctl -p

Output:

[root@vps ~]# echo 'net.core.default_qdisc=fq' | tee -a /etc/sysctl.conf
net.core.default_qdisc=fq
[root@vps ~]# echo 'net.ipv4.tcp_congestion_control=bbr' | tee -a /etc/sysctl.conf
net.ipv4.tcp_congestion_control=bbr
[root@vps ~]# sysctl -p
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr

Run the following command to verify if BBR is enabled,

sysctl net.ipv4.tcp_available_congestion_control

Output:

[root@vps ~]# sysctl net.ipv4.tcp_available_congestion_control
net.ipv4.tcp_available_congestion_control = reno cubic bbr

Finally, execute the following command to verify the Google BBR,

lsmod | grep bbr

Output:

[root@vps ~]# lsmod | grep bbr
tcp_bbr                20480  1

Congratulations! You have successfully installed TCP BBR Congestion Control.