Measuring Latency
# Round-trip time (RTT)
ping -c 10 YOUR_SERVER_IP
# More detailed
mtr --report YOUR_SERVER_IP
Normal latency:
- Same continent: 5-30ms
- Cross-continent: 100-200ms
- Global: 200-400ms
Find Latency Bottleneck
Using mtr (My TraceRoute):
mtr YOUR_SERVER_IP
Look for hop with high loss or high latency jump.
Fix 1: Choose Nearest Data Center
When creating VPS, select location closest to your users.
Hostxpeed offers multiple locations. Migrate if needed.
Fix 2: Use CDN for Content
Cloudflare, BunnyCDN, etc. cache static content globally.
Fix 3: Enable TCP BBR (Congestion Control)
# Enable BBR
sudo modprobe tcp_bbr
echo "tcp_bbr" | sudo tee -a /etc/modules-load.d/modules.conf
# Set congestion control
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
# Verify
sysctl net.ipv4.tcp_congestion_control
Fix 4: Optimize TCP Settings
# Increase buffer sizes
echo "net.core.rmem_max = 134217728" >> /etc/sysctl.conf
echo "net.core.wmem_max = 134217728" >> /etc/sysctl.conf
echo "net.ipv4.tcp_rmem = 4096 87380 134217728" >> /etc/sysctl.conf
echo "net.ipv4.tcp_wmem = 4096 65536 134217728" >> /etc/sysctl.conf
sudo sysctl -p
Fix 5: Check for Packet Loss
Packet loss increases effective latency due to retransmissions:
# Test packet loss
ping -c 100 YOUR_SERVER_IP | grep loss
Loss > 1% indicates network problem. Contact Hostxpeed if internal.
Fix 6: Use HTTP/2 or HTTP/3
Enable HTTP/2 in Nginx/Apache for multiplexed connections.