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 as1
: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.