Boost VPS Network Speed with TCP BBR
TCP BBR (Bottleneck Bandwidth and Round-trip propagation time) is a congestion control algorithm developed by Google that increases throughput and reduces latency, especially on connections with minor packet loss. It can be easily enabled on Linux kernel 4.9+ without needing to recompile the kernel.
Check Kernel and Enable BBR
# Check kernel version (requires 4.9+)
uname -r
# View current congestion control
sysctl net.ipv4.tcp_congestion_control
# View available algorithms
sysctl net.ipv4.tcp_available_congestion_control
# Enable BBR (takes effect immediately, no reboot needed)
sudo modprobe tcp_bbr
echo "tcp_bbr" | sudo tee -a /etc/modules-load.d/modules.conf
# Configure sysctl
sudo tee -a /etc/sysctl.conf << 'EOF'
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
EOF
sudo sysctl -p
Additional Kernel Network Tuning
Adjust kernel parameters to improve performance for web servers handling many connections:
sudo tee -a /etc/sysctl.conf << 'EOF'
# Increase socket buffers
net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
net.ipv4.tcp_rmem = 4096 87380 134217728
net.ipv4.tcp_wmem = 4096 65536 134217728
# Increase connection queue
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
# TIME_WAIT optimization
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 15
# Enable IP forwarding (if using as router/NAT)
# net.ipv4.ip_forward = 1
EOF
sudo sysctl -p
net.core.somaxconn setting must also be configured in your application. For example, Nginx requires listen 80 backlog=65535 in its config; otherwise the application will cap it at a lower value.
Test Speed Before and After
# Install speedtest tool
sudo apt install speedtest-cli -y
speedtest
# Test TCP throughput between two VPS instances (requires both server and client)
# On server
iperf3 -s
# On client
iperf3 -c SERVER_IP -t 30
Verify BBR is Working Correctly
# Check current congestion control
sysctl net.ipv4.tcp_congestion_control
# Should return: net.ipv4.tcp_congestion_control = bbr
# Check qdisc
tc qdisc show | grep fq
# View BBR stats for active connections
ss -tin | grep bbr | head -5
# Verify module is loaded
lsmod | grep bbr
Common Issues & Troubleshooting
Error: "modprobe: FATAL: Module tcp_bbr not found"
Your kernel is too old or your VPS uses OpenVZ virtualization, which shares the kernel with the host and cannot load additional modules:
# Check kernel version
uname -r # requires 4.9+
# Check virtualization type
systemd-detect-virt
# If OpenVZ, you'll get "openvz"
# Request your provider to enable BBR at the host level instead
sysctl -p Reports "No such file or directory" for Some Values
Some parameters may not exist in your kernel version, or the module hasn't loaded yet. Try applying only supported values:
# Apply while skipping errors
sudo sysctl --system 2>&1 | grep -v "No such file"
# Or apply values one at a time
sudo sysctl net.ipv4.tcp_congestion_control=bbr
BBR Settings Disappear After Reboot
The modprobe and sysctl -w changes are temporary. You must save them permanently in two places:
# 1. Save the module
echo "tcp_bbr" | sudo tee /etc/modules-load.d/tcp_bbr.conf
# 2. Save sysctl settings
sudo tee /etc/sysctl.d/99-bbr.conf << 'EOF'
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
EOF
# Test after reboot
sudo reboot
# After reboot:
sysctl net.ipv4.tcp_congestion_control
Nginx Connections Still Slow Despite BBR
BBR works at the TCP layer, but Nginx also needs proper backlog and worker connection settings:
sudo nano /etc/nginx/nginx.conf
events {
worker_connections 65535;
use epoll;
multi_accept on;
}
# And in server block:
listen 80 backlog=65535;
Frequently Asked Questions
How is BBR Different from CUBIC?
CUBIC (the older algorithm) adjusts window size based on packet loss. When loss occurs from buffer overflow (bufferbloat), CUBIC reduces the window more than necessary. BBR adjusts based on actual bandwidth and RTT, resulting in higher throughput and lower latency under real-world network conditions.
Is BBR Suitable for All Use Cases?
BBR is excellent for: web servers, file transfers, and video streaming. BBR may show less benefit on: high-speed LAN with very low latency (uncommon in VPS environments). Some reports indicate BBR uses bandwidth more aggressively than CUBIC under congestion.
Are These sysctl Settings Safe for All Applications?
Generally safe for typical web servers, but the tcp_tw_reuse setting may have side effects on applications sensitive to TIME_WAIT state. If you experience connection issues after applying these settings, disable tcp_tw_reuse first.