Tuning Linux TCP BBR and Fair Queueing on Cloud Virtual NICs

· Daniel Lin linuxnetworkingtcpbbr

Switching a Linux server from cubic to bbr over transpacific links often yields dramatic throughput gains under minor packet loss (0.5% to 2%). However, one detail is frequently overlooked: BBR relies on packet pacing, and pacing works best when paired with the fq (Fair Queue) scheduler.

The Subtle Trap with Live Interfaces

Setting net.core.default_qdisc = fq via sysctl only affects newly created interfaces or queues initialized at boot. On an already running cloud VM using a multi-queue virtio NIC (mq), existing TX queues often stay attached to fq_codel until either a reboot or an explicit queue reload:

# Persist BBR + fq across reboots
cat <<'EOF' > /etc/sysctl.d/99-bbr.conf
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
EOF
sysctl --system

# Re-initialize mq sub-queues with the new default qdisc without dropping SSH
tc qdisc replace dev ens4 root mq
tc qdisc show dev ens4

Benchmark Summary (Taipei ↔ Frankfurt, 1.2% Synthetic Loss)

ConfigurationSingle-Stream Throughputp95 RTT Under Load
cubic + fq_codel18.4 Mbps294 ms
bbr + fq142.7 Mbps221 ms
← Memory Fragmentation in Long-Lived Go Services: GOGC and GOMEMLIMIT in PracticeBuilding Deterministic Container Images with Multi-Stage Distroless Builds →