Vps opens BBR acceleration (CentOS 7)

Posted by Spinicrus on Wed, 17 Jul 2019 21:45:31 +0200

vps of vultr, bought last month, still feel slow to watch videos, so look for tutorials online, open BBR acceleration here and record it, which may be used later.

BBR is a new congestion control algorithm proposed by Google, which can significantly improve the throughput of Linux servers and reduce the delay of TCP connections.

BBR solves two problems:

In addition, the bandwidth is fully utilized on the network links with a certain packet loss rate. It is very suitable for high delay and high bandwidth network links.

Reducing buffer occupancy on network links reduces latency. It is very suitable for users with slow access network.

 

High latency and high bandwidth. Isn't that me?

Upgrade Kernel

Opening BBR requires more than 4.10 versions of the Linux kernel. You can view the current version of the kernel using the following commands:

uname -r

Get:

3.10.0-957.12.2.el7.x86_64

It was found that less than 4.10 was updated using ELRepo source:

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
sudo yum --enablerepo=elrepo-kernel install kernel-ml -y

After installation, check the installed kernel:

rpm -qa | grep kernel

The results are as follows:

kernel-tools-3.10.0-957.12.2.el7.x86_64
kernel-headers-3.10.0-957.21.2.el7.x86_64
kernel-ml-5.2.1-1.el7.elrepo.x86_64
kernel-tools-libs-3.10.0-957.12.2.el7.x86_64
kernel-3.10.0-957.12.2.el7.x86_64
kernel-3.10.0-957.el7.x86_64

I'm upgrading directly to 5.2.1...

Modify grub2 boot

Implementation:

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

Get:

CentOS Linux 7 Rescue a56038a8b7c142aba2be7bb948369660 (5.2.1-1.el7.elrepo.x86_64)
CentOS Linux (5.2.1-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.12.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-a9fa8fe7b3214c368cdebd8c7e36dd85) 7 (Core)

Set the default startup item to 1 and restart the system:

sudo grub2-set-default 1
reboot

After the restart is complete, log in again and run the uname command again to confirm that you are using the correct kernel:

uname -r

Get:

5.2.1-1.el7.elrepo.x86_64

Now you can turn on BBR

Open BBR

Implementation:

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

After completion, the following commands are executed to check whether the BBR is successfully turned on:

sudo sysctl net.ipv4.tcp_available_congestion_control
# The output should be echo 'net.ipv4.tcp_congestion_control=bbr' | sudo tee -a/etc/sysctl.conf

sudo sysctl -n net.ipv4.tcp_congestion_control
# The output should be bbr

lsmod | grep bbr
# The output should be similar tcp_bbr          20480  2 

Now that BBR is properly turned on, you can use speed test-cli to test Download speed.

Speed test is a command-line script written in python, which completes speed test by calling the interface of speed test. net test up and down.

Installing speedtest-cli requires Python 2.7.5 on my vps in Python 2.4-3.4 environments.

But downloading speedtest-cli requires pip. I tried to find that there is no pip on vps. So I had to download PIP first.

setuptools need to be installed before pip is installed

yum install -y python-setuptools

Once installed, the easy_install command can be used.

Install pip

easy_install pip

Installing pip through easy_install is the simplest way. pip is installed in the / usr/bin directory by default.

Now you can download speedtest-cli

Install speedtest-cli

 

pip install speedtest-cli

 

Speed test-cli usage

  • speedtest-cli --help: Display help
  • Speed test-cli -- list: Displays a list of test servers for speedtest.net based on distance
  • Speed test-cli -- server: Servers that specify id in the list for testing
  • Speed test-cli--share: Share your network speed. This command generates pictures of the results of the speed test on the speedtest website

Speed test-cli test

Display all test servers in China

 

speedtest-cli --list | grep China

 

Get:

 5460) China Unicom Heilongjiang Branch (Harbin, China) [10635.51 km]
 9484) China Unicom (Changchun, China) [10867.65 km]
16375) China Mobile,Jilin (Changchun, China) [10867.65 km]
17222) China Mobile Group XinJiang (Aletai, China) [10908.38 km]
16167) ChinaMobile, Liaoning Branch (Shenyang, China) [11133.48 km]
17228) China Mobile Group XinJiang (Yili, China) [11255.62 km]
 6144) xjunicom (Urumqi, China) [11351.08 km]
16858) China Mobile Group XinJiang (Urumqi, China) [11351.08 km]
25728) ChinaMobile, Liaoning Branch,Dalian (Dalian, China) [11497.00 km]
25858) China Mobile Group Beijing Co.Ltd (Beijing, China) [11545.16 km]
 4713) China Mobile Group Beijing Co.Ltd (Beijing, China) [11545.16 km]
25316) Beijing Connect Trunk (Tianjin, China) [11579.57 km]
17184) China Mobile,TianJin (Tianjin, CN) [11606.60 km]
 5475) China Unicom (Tianjin, China) [11606.60 km]
17245) China Mobile Group XinJiang (Kashi, China) [11624.88 km]
 5563) JINAN Wo China company (Jinan, China) [11872.31 km]
 5039) China unicom Jinan branch (Jinan, China) [11872.31 km]
17480) China Moible, ShanDong Branch (Jinan, China) [11872.31 km]
17227) China Mobile Group XinJiang (Hetian, China) [11967.02 km]
 5317) China Telecom JiangSu Branch (Lianyungang, China) [12023.07 km]
 5396) China Telecom JiangSu Branch (Suzhou, China) [12119.21 km]
 5509) Chinaunicom Ningxia branch (Ningxia, China) [12123.49 km]
 5992) Qinghai China Unicom (Xining, China) [12158.60 km]
 4690) China Unicom Lanzhou Branch Co.Ltd (Lanzhou, China) [12204.68 km]
 3973) China Telecom (Lanzhou, China) [12204.68 km]
16145) Lanzhou,China Mobile,Gansu (Lanzhou, China) [12204.68 km]
21005) China Unicom (Shanghai, China) [12293.93 km]
25637) Chinamobile-5G (Shanghai, China) [12293.93 km]
24447) China Unicom 5G (ShangHai, China) [12293.93 km]
13704) China Unicom (Nanjing, China) [12299.63 km]
 5316) China Telecom JiangSu Branch (Nanjing, China) [12301.68 km]
17145) China Telecom AnHui Branch (Hefei, CN) [12368.45 km]
 5724) ChinaUnicom (Hefei, China) [12368.45 km]
 6715) China Mobile Group Zhejiang Co., Ltd. (Ningbo, China) [12428.56 km]
 7509) China Telecom ZheJiang Branch (Hangzhou, China) [12440.13 km]
 4647) China Mobile Group Zhejiang Co.,Ltd (Hangzhou, China) [12440.13 km]
 5485) China Unicom,Hubei Branch (Wuhan, China) [12592.63 km]
24011) China Telecom Wuhan Branch-2 (Wuhan, China) [12592.63 km]
23844) China Telecom Wuhan Branch (Wuhan, China) [12592.63 km]
16332) China Mobile Group JiangXi CO.,Ltd (Nanchang, China) [12746.87 km]
24337) China Mobile Group Sichuan Co.,Ltd. (Chengdu, China) [12793.94 km]
 5726) China Unicom Chong Qing Branch (Chongqing, China) [12877.21 km]
 5530) CCN (Chongqing, China) [12877.21 km]
 4884) China Unicom FuJian (Fuzhou, China) [12902.24 km]
18444) China Mobile Group Tibet (Lhasa, China) [12946.04 km]
16398) China Mobile,GuiZhou (Guiyang, China) [13194.20 km]
17251) ChinaTelecom-GZ (Guangzhou, CN) [13414.40 km]
 6611) China Mobile,Guangdong (Guangzhou, China) [13414.40 km]
 5103) Yunnan Chinaunicom (Kunming, China) [13427.97 km]
 4515) China Mobile,Guangdong (Shenzhen, China) [13451.25 km]
 2993) Website Solution Limited (Hong Kong, China) [13480.14 km]
 1536) STC (Hong Kong, China) [13480.14 km]
12990) QTS Data Centers (Hong Kong, China) [13480.14 km]
22724) GX-Telecom_1 (Nanning, China) [13578.02 km]
15863) GX ChinaMobile (Nanning, China) [13578.02 km]
10305) GX-Telecom (Nanning, China) [13578.02 km]
16503) Chinamobile,Hainan (Haikou, China) [13828.05 km]

The server number, operator, location and distance from my server are shown here because I bought an American server (Japan is cheap and fast, but it sold out 555...) so the distance is tens of thousands of kilometers.

Speed test:

speedtest-cli --server=16503 --share 

Here I choose mobile operators:

 

It's still slower... Change to another operator:

speedtest-cli --server=5563 --share

It's obviously faster.

I am the network card of Telecom. YouTube is basically no card at 480P now, but I haven't reached the 4K card mentioned in the online tutorial. Maybe it's the operator's problem.

Topics: PHP Mobile sudo pip Linux