BBR is an open-source TCP network congestion optimization algorithm developed by Google, which can accelerate the access speed from visitors to your server. Especially for overseas servers, enabling the BBR algorithm can provide
Website Optimizationsome assistance. Here, Naiba will use the CentOS7 system to demonstrate how to install the new kernel version (because BBR requires kernel 4.9 or higher) and enable BBR acceleration.
Steps to Install New Kernel on CentOS7
First, check the current server's kernel version.
uname -sr
The uname command is used to print information about the current system (kernel version, hardware architecture, hostname, and operating system type, etc.).
-a或--all:显示全部的信息;
-m或--machine:显示电脑类型;
-n或-nodename:显示在网络上的主机名称;
-r或--release:显示操作系统的发行编号;
-s或--sysname:显示操作系统名称;
-v:显示操作系统的版本;
-p或--processor:输出处理器类型或"unknown";
-i或--hardware-platform:输出硬件平台或"unknown";
-o或--operating-system:输出操作系统名称;
--help:显示帮助;
--version:显示版本信息。
BBR requires kernel 4.9+. Typically, the kernel version output by the above command is around 3.x. Next, enable the ELRepo repository.
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

Then install the new stable kernel version.
yum --enablerepo=elrepo-kernel install kernel-ml -y
After installation, use the following command to check if the installation was successful.
rpm -qa | grep kernel
My display is as follows:
kernel-3.10.0-862.14.4.el7.x86_64
kernel-ml-5.3.8-1.el7.elrepo.x86_64
kernel-3.10.0-1062.4.1.el7.x86_64
kernel-headers-3.10.0-1062.4.1.el7.x86_64
kernel-3.10.0-957.5.1.el7.x86_64
kernel-3.10.0-1062.1.2.el7.x86_64
kernel-tools-3.10.0-1062.4.1.el7.x86_64
kernel-tools-libs-3.10.0-1062.4.1.el7.x86_64
kernel-3.10.0-957.1.3.el7.x86_64
Here, kernel-ml-5.3.8-1.el7.elrepo.x86_64 is the newly installed kernel version (the kernel version may have changed by the time you read this tutorial, so adapt accordingly). Next, set the system boot order using the following command.
sudo egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
My display is as follows:
CentOS Linux (5.3.8-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-1062.4.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-1062.1.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.5.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.1.3.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-862.14.4.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-618ca2de6e204efbb013b592564ef36a) 7 (Core)
The first entry is CentOS Linux (5.3.8-1.el7.elrepo.x86_64) 7 (Core). Count from the first row as 0, 1, 2, 3, etc., to see which number your new kernel is. Then enter the following command (example command for row 1).
sudo grub2-set-default 0
Next, reboot the server.
reboot
Check the kernel version again.
uname -r
If the kernel version shows 4.9 or higher (at the time of this update, the new version is 5.3.8), it proves the installation was successful. Rebuild the kernel configuration.
grub2-mkconfig -o /boot/grub2/grub.cfg
Reboot the system to verify; if there are no issues, it's OK.
Enable BBR on CentOS7 New Kernel
To enable the new kernel on the freshly installed CentOS7, simply copy and execute the code below.
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
Then enter the following command to check if BBR was successfully enabled.
sudo sysctl net.ipv4.tcp_available_congestion_control
If successful, the output should look like this.
net.ipv4.tcp_available_congestion_control = bbr cubic reno
Continue verification.
sudo sysctl -n net.ipv4.tcp_congestion_control
The output should be.
bbr
Finally, check if the kernel module is loaded.
lsmod | grep bbr
The output should be similar to the following.
tcp_bbr 16384 0
What is the purpose of enabling BBR?
In simple terms, enabling BBR can provide some optimization for your website's access speed. For example, Naiba's notes use WordPress; BBR can also offer some acceleration optimization for WordPress sites. Of course, since Naiba uses a domestic server, the BBR acceleration effect may not be very significant. BBR is an open-source TCP network congestion optimization algorithm developed by Google. TCP BBR aims to solve two problems: fully utilizing bandwidth on network links with some packet loss rate, and reducing buffer occupancy on network links to lower latency. The goal of TCP congestion control is to maximize the utilization of bandwidth on bottleneck links in the network. Open-source address:
https://github.com/google/bbrBBR and BBR2 One-Click Packages
What is BBR2?
BBR2 is currently still in preview; it is an upgraded version of BBR and is not yet mature enough, so it is not recommended for production environments. For detailed information on BBR2, refer to:
https://github.com/google/bbr/blob/v2alpha/README.mdThe documentation also includes a tutorial and steps for manually installing BBR2, which will not be copied here.
bbr2 one-click package
Warning: Changing the kernel carries risks. We are not responsible for any losses incurred if the system fails to boot after using this script. Recommended system: Debian 10 x86_64. Theoretically supports Debian 8+, Ubuntu 16.04+. Only applicable to KVM virtualized VPS. Do not attempt on OpenVZ, Xen, or Dedicated Servers. Only applicable to 64-bit (x86_64) systems; x86 is not supported,
CentOS and other systems are not supported. Tested successfully on BandwagonHost Debian 8, 9, 10, and Ubuntu 16.04, 18.04 (Ubuntu 14.04 failed). Tested successfully on Debian 10 systems from the following providers: Oracle Public Cloud, DMIT, OLVPS, AlibabaCloud. Debian 10 installation success rate is 100%. CentOS users are advised to use BBR or attempt manual installation of BBR2.
wget --no-check-certificate -q -O bbr2.sh "https://raw.githubusercontent.com/yeyingorg/bbr2.sh/master/bbr2.sh" && chmod +x bbr2.sh && bash bbr2.sh auto
Important! Please reboot the system after enabling/disabling BBR/ECN. It has been discovered that the script may have bugs causing it not to take effect or to coexist with old acceleration methods like BBR.BBR one-click package
The BBR one-click package supports more systems, but the prerequisite is that the kernel version must support BBR. If the kernel version is insufficient, you still need to manually update the kernel. System support: CentOS 6+, Debian 7+, Ubuntu 12+. Virtualization technology: All except OpenVZ, such as KVM, Xen, VMware, etc. Memory requirement: ≥128M
wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
bbr plus one-click package
BBR Plus is an optimization of the original BBR parameters, which may provide better acceleration performance on certain machines. The BBR Plus one-click installation script introduced in this article is from netizen cx9208. In addition to BBR Plus, it also integrates one-click installations for the original BBR, modified BBR, and LotServer (ServerSpeeder), making it a four-in-one version where you can switch between the four. Applicable architecture: KVM / Xen; OpenVZ (OVZ) is not supported. Applicable systems: CentOS 7, Debian 8, Debian 9, Ubuntu 16.04, Ubuntu 18.04.
wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
Comments are closed
The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.