BBR (Bottleneck Bandwidth and RTT) congestion control algorizthm is a new congestion control algorithm which is contributed to the Linux kernel TCP stack by Google.
With TCP BBR in place, a Linux server can get significantly increased throughput and reduced latency for connections in most cases, especially for your VPS server that dedicated for Web service or VPN. Besides, it’s easy to deploy TCP_BBR as we just need to upgrade the kernel and enable BBR on server side.
In this article, I will show you how to deploy BBR on a CentOS 7 server.
Step 1: Upgrade the kernel to version 4.9+
In order to use TCP_BBR, we need to upgrade the kernel to 4.9.0(or later versions). We can easily get that done using some 3rd-party RPM repository.
The repos that I use most are ELRepo and Spaceduck. I will use Spaceduck for reference.
Step1.1 setup the repository file for kernel yum install.
This can be easily done with below command:
curl -k https://yum.spaceduck.org/kernel-ml-aufs/kernel-ml-aufs.repo -o /etc/yum.repos.d/kernel-ml-aufs.repo
Step1.2 install the latest main-line kernel
Note that the name of new kernel in Spaceduck is kernel-ml-aufs, the rename eliminate some potential naming conflict, so let’s take the new kenrel as a brand-new package. Install the kernel,
yum install -y kernel-ml-aufs
Step 1.3 Set booting order for new kernel in Grub2
Since new kernel installed, we need to set default booting kernel to it in Grub 2. This can be done by reseting saved_entry to the specified menu entry.
To list all the menu entries that will be displayed at system boot, issue the following command:
# grep "^menuentry" /boot/grub2/grub.cfg | cut -d "'" -f2 CentOS Linux (4.9.9-1.el7.centos.x86_64) 7 (Core) CentOS Linux (4.9.9-1.el7.centos.x86_64) 7 (Core) with debugging CentOS Linux (3.10.0-514.6.2.el7.x86_64) 7 (Core) CentOS Linux (3.10.0-514.6.2.el7.x86_64) 7 (Core) with debugging
Update saved_entry to new kernel:
grub2-set-default 'CentOS Linux (4.9.9-1.el7.centos.x86_64) 7 (Core)'
Step 1.4 Reboot server to make the new kernel take effect.
Fire the command “reboot” as root.
Step 2: Update sysctl settings to enable BBR
Create a new file named “/etc/sysctl.d/88-tcp_bbr.conf”, with below content,
Then run “sysctl -p/etc/sysctl.d/88-tcp_bbr.conf” to make new settings take effect.
Make sure we are all set, make sure the kernel we use is the right one, and new settings work.
# uname -r 4.9.9-1.el7.centos.x86_64 # sysctl net.core.default_qdisc net.ipv4.tcp_congestion_control net.core.default_qdisc = fq net.ipv4.tcp_congestion_control = bbr
Now enjoying the new settings.