This article was contributed by Dustin B. Cisneros of RackNerd – LowEndBox appreciates your contribution as always! Be sure to check out RackNerd’s latest LowEndBox specials if you are looking for a KVM VPS.
Google’s TCP BBR, or “Bottleneck Bandwidth and Round-trip propagation time,” is a congestion control system based on cutting-edge technology. It is the same system used for traffic through Google.com, as well as YouTube. It was the reason that YouTube’s network throughput was increased by 4% annually. Moreover, Google’s BBR also significantly reduces latency as the querying, and queuing delays are minimized.
We have written this guide for you so that you can enable Google’s BBR on your Linux virtual private server.
There would be two steps in the guide, where step 1 can be optional in some instances. Let us start!
Step 1. Check and upgrade your kernel
We need Linux kernel version 4.9.0 or higher to support Google’s BBR. We will guide you on how to update it for both CentOS 7 and Ubuntu.
To check your current kernel version, run this command:
uname -r
If this command returns a kernel version higher than 4.9.0, then you can skip step 1.
CentOS 7 Based Systems:
1) Install Elrepo repo
To update the CentOS kernel, we need to install the Elrepo repo via the following commands:
sudo rpm –import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
sudo rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
2) Update your kernel
To install the updated kernel, run the following two commands:
sudo yum –enablerepo=elrepo-kernel install kernel-ml -y
yum list installed kernel
3) Set default boot entry
Run this command to see the list of kernels:
sudo egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \’
You should find your newly installed kernel at the top of the list. Then run the following command:
sudo grub2-set-default 0
4) Reboot and verify
Now reboot your VPS, and after it turns back on, rerun the following command to verify the install:
uname -r
Ubuntu 18.04 Based Systems
The kernel version should be compatible with Google’s BBR if you are running Ubuntu 18.04. However, you can still upgrade the kernel using the following commands.
cd /tmp/
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.13/linux-headers-5.4.13-050413_5.4.13-050413.202001171431_all.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.13/linux-headers-5.4.13-050413-generic_5.4.13-050413.202001171431_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.13/linux-headers-5.4.13-050413-lowlatency_5.4.13-050413.202001171431_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.13/linux-image-unsigned-5.4.13-050413-generic_5.4.13-050413.202001171431_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.13/linux-image-unsigned-5.4.13-050413-lowlatency_5.4.13-050413.202001171431_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.13/linux-modules-5.4.13-050413-generic_5.4.13-050413.202001171431_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.13/linux-modules-5.4.13-050413-lowlatency_5.4.13-050413.202001171431_amd64.deb
sudo dpkg -i *.deb
After running the commands, reboot your VPS by running the “reboot” command.
Step 2. Enable Google’s TCP BBR
The instructions below are the same for both CentOS and Ubuntu.
To start, open “/etc/sysctl.conf” in any text editor, or run the command to open it in vim or nano (your preferred text editor):
sudo vim /etc/sysctl.conf
At the end of the config file, add the following lines:
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
Then save the file, and refresh your configuration using this command:
sudo sysctl -p
Google’s BBR congestion control system has now been enabled on your VPS, to verify this, run this command:
sysctl net.ipv4.tcp_congestion_control
If the enabling process were successful, the output would be:
net.ipv4.tcp_congestion_control = bbr
You have now successfully enabled Google’s TCP BBR on your VPS!
Have you enabled Google’s TCP BBR on your Linux VPS? Have you seen any performance benefits? Please leave your questions or feedback in the comments section below!
Related Posts:
- Have you ever visited the web’s busiest hosting forum? LowEndTalk awaits. - September 27, 2022
- Grab the deals first by subscribing to our new deal alerts - September 16, 2022
- LowEndBox is on Instagram and TikTok! - August 5, 2022
# https://pastebin.com/agDpaRTh
# author: andre boyce
# license: GPLV2
# version: 1
# copy paste ready
# Enable Google’s TCP BBR on a Linux VPS
# creates 2 files enable_google_tcp_bbr disable_google_tcp_bbr
# todo maybe add quiet option
# maybe make sed commands fit on one line
# make a directory called scripts in the home directory
mkdir -p ~/scripts
# move in to the scripts directory
cd ~/scripts
# create a file called enable_google_tcp_bbr
touch enable_google_tcp_bbr
# make the file executable
chmod +x enable_google_tcp_bbr
# echo this script in to the file
echo ‘
# Enable Google’s TCP BBR on a Linux VPS
# tested on ununtu 20.04, centos 8
# run as root or as user with sudo
# get the major_version of the kernel by splitting the result of uname -r by “.” first column. e.g. 2.4.0 should give 2
major_version=$(uname -r | awk -F”.” ‘\”{print $1}’\”)
# get the minor_version of the kernel by splitting the result of uname -r by “.” second column. e.g. 2.4.0 should give 4
minor_version=$(uname -r | awk -F”.” ‘\”{print $2}’\”)
# if major_version of kernel less than 4.x.x
if [ “$major_version” -lt “4” ]
then
echo “Kernel version is: $major_version.$minor_version which is too low please upgrade kernel to version 4.9.0 or greater”
echo -e “\033[0;31mFailed\033[m” && exit 1;
else
# if major_version of kernel is equal to 4.x.x then check if minor version less than 6
if [ “$major_version” -eq “4” ] && [ $minor_version -lt “9” ]
then
echo “Kernel version is: $major_version.$minor_version which is too low please upgrade kernel to version 4.9.0 or greater”
echo -e “\033[0;31mFailed\033[m” && exit 1;
else
echo “Kernel version is: $major_version.$minor_version which is ok”
fi
fi
# backup /etc/sysctl.conf
yes | sudo cp /etc/sysctl.conf /etc/sysctl.conf.bak
# if we find “net.core.default_qdisc=fq” in /etc/sysctl.conf
if sudo grep -Fq “net.core.default_qdisc=fq” /etc/sysctl.conf
then
# echo “net.core.default_qdisc=fq present in /etc/sysctl.conf”
:
else
echo “net.core.default_qdisc=fq” | sudo tee -a /etc/sysctl.conf
fi
# if we find “net.ipv4.tcp_congestion_control=bbr” in /etc/sysctl.conf
if sudo grep -Fq “net.ipv4.tcp_congestion_control=bbr” /etc/sysctl.conf
then
# echo “net.ipv4.tcp_congestion_control=bbr present in /etc/sysctl.conf”
:
else
echo “net.ipv4.tcp_congestion_control=bbr” | sudo tee -a /etc/sysctl.conf
fi
# show differences
# sudo diff /etc/sysctl.conf /etc/sysctl.conf.bak
# Reload configuration
sudo sysctl -qp
# if it worked then expected output net.ipv4.tcp_congestion_control = bbr
if sudo sysctl net.ipv4.tcp_congestion_control | grep -q “net.ipv4.tcp_congestion_control = bbr” ; then echo -e “\033[0;32mSuccess\033[m” && exit 0; else echo -e “\033[0;31mFailed\033[m” && exit 1; fi
‘ > ~/scripts/enable_google_tcp_bbr
# execute the script we created
./enable_google_tcp_bbr
# create another file to disable google_tcp_bbr
touch disable_google_tcp_bbr
chmod +x disable_google_tcp_bbr
cat > ~/scripts/disable_google_tcp_bbr << EOF
# remove net.core.default_qdisc=fq from /etc/sysctl.conf
# remove net.ipv4.tcp_congestion_control=bbr from /etc/sysctl.conf
# if we find "net.core.default_qdisc=fq" in /etc/sysctl.conf
if sudo grep -Fq "net.core.default_qdisc=fq" /etc/sysctl.conf
then
# note would be nice to get sed to do this in one line
# remove net.ipv4.tcp_congestion_control=bbr from /etc/sysctl.conf
sudo sed -i "s/^net\.core\.default_qdisc\=fq//" /etc/sysctl.conf
# remove trailing empty lines
sudo sed -Ezi '$ s/\n+$//' /etc/sysctl.conf
echo -e "" | sudo tee -a /etc/sysctl.conf
echo "net.core.default_qdisc=fq removed from /etc/sysctl.conf"
else
echo "net.core.default_qdisc=fq not found in /etc/sysctl.conf"
fi
# if we find "net.ipv4.tcp_congestion_control=bbr" in /etc/sysctl.conf
if sudo grep -Fq "net.ipv4.tcp_congestion_control=bbr" /etc/sysctl.conf
then
# note would be nice to get sed to do this in one line
# remove net.ipv4.tcp_congestion_control=bbr from /etc/sysctl.conf
sudo sed -i "s/^net\.ipv4\.tcp_congestion_control\=bbr//" /etc/sysctl.conf
# remove trailing empty lines
sudo sed -Ezi '$ s/\n+$//' /etc/sysctl.conf
echo -e "" | sudo tee -a /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr removed from /etc/sysctl.conf"
else
echo "net.ipv4.tcp_congestion_control=bbr not found in /etc/sysctl.conf"
fi
# Reload configuration
sudo sysctl -qp
if ! sudo grep -Fq "net.core.default_qdisc=fq" /etc/sysctl.conf && ! sudo grep -Fq "net.ipv4.tcp_congestion_control=bbr" /etc/sysctl.conf ; then echo -e "\033[0;32mSuccess\033[m" ; exit 0; else echo -e "\033[0;31mFailed\033[m" ; exit 1; fi
EOF
ls
Earlier today I posted a copy and paste ready script that could activate Google’s TCP BBR.
It would check the kernel version and if it was >= 4.9.0 would activate it.
It appears to have been removed. Is there some rule against posting scripts?
https://pastebin.com/agDpaRTh
I have try using centos 7 but kernel not change still 3.10, what happen?
Thanks
Hi Yuandri Trisaputra, thank you for commenting!
Out of curiosity is your virtual machine OpenVZ or KVM? If it is OpenVZ, please note that OpenVZ kernel cannot be changed, it shares the same kernel as the host node.
I see. I think my vps is openvz.
Thank you.
Hi Yuandri Trisaputra, no worries, happy I could help.
By the way if you’re looking a KVM VPS deal, or what we’d called a steal for the price :P Check out: https://my.racknerd.com/cart.php?a=add&pid=279