Last active
September 19, 2023 16:27
-
-
Save sammdu/668070b486832f47f3b0da2200a7954f to your computer and use it in GitHub Desktop.
Significantly increase TCP throughput (and thus network speed) of your Linux server. When I tried it on a VPS I own, the wget average went from 394KB/s to 1.37MB/s!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# This is a crazy feature of the Linux kernel that will DRAMATICALLY increase | |
# the TCP throughput (and thus network speed) of your Linux server. | |
# When I tried it on a VPS I own, the wget average went from 394KB/s to 1.37MB/s! | |
# Further reading: https://medium.com/google-cloud/tcp-bbr-magic-dust-for-network-performance-57a5f1ccf437 | |
# check if kernel supports TCP BBR | |
if ! grep 'CONFIG_TCP_CONG_BBR' /boot/config-"$(uname -r)" | grep -q 'CONFIG_TCP_CONG_BBR'; then | |
echo "" | |
echo "Your kernel does not support TCP BBR." | |
echo "Make sure you have the latest kernel installed, and is not using OpenVZ virtualization." | |
echo "" | |
exit 0 | |
fi | |
# if kernel supports TCP BBR, then check if it has been enabled | |
echo "" | |
sysctl net.core.default_qdisc | |
sysctl net.ipv4.tcp_congestion_control | |
echo "" | |
# if already enabled, notify user, take no further action, exit script | |
if sysctl net.core.default_qdisc | grep -q 'fq' && sysctl net.ipv4.tcp_congestion_control | grep -q 'bbr'; then | |
echo "TCP BBR Congestion Control is already ENABLED in your system!" | |
echo "No further action necessary." | |
echo "" | |
exit 0 | |
fi | |
# pause and advise the user to speedtest before continuing | |
echo "" | |
echo "Congratulations! Your kernel DOES support TCP BBR!" | |
echo "You might want to exit the script now and test the download speed to compare afterwards." | |
echo "" | |
echo " Press Ctrl+C to exit," | |
read -p " press [Enter] to continue..." | |
echo "" | |
# edit TCP BBR settings | |
sudo touch /etc/sysctl.d/10-custom-kernel-bbr.conf | |
echo "net.core.default_qdisc=fq" | sudo tee -a /etc/sysctl.d/10-custom-kernel-bbr.conf | |
echo "net.ipv4.tcp_congestion_control=bbr" | sudo tee -a /etc/sysctl.d/10-custom-kernel-bbr.conf | |
# apply the changes | |
sudo sysctl --system | |
# verify | |
echo "" | |
sysctl net.core.default_qdisc | |
sysctl net.ipv4.tcp_congestion_control | |
echo "" | |
# exit message | |
echo "" | |
echo "All the settings have been applied!" | |
echo "You might want to reboot the server and test the download speed again." | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment