Finetune Linux Network
A few tips annd tricks to boost network performance on linux
Linux Network Fine-tuning
Are you a linux user trying to squeeze the most of your machine in terms of network latency? Look no further!
This time we explore a few tips that would help you get the most of your system.
NOTE: Some changes require a reboot to take effect.
Disable Power Saving
The simplest change you could do would be to disable powersaving for your WiFi. You might have probably guessed by now, but this change does come at the tradeoff of higher power consumtion. In my personal experience it is not very signifcant.
Using iw
Executing ifconfig would give you a list of network interfaces, after you find your wireless interface, execute,
sudo iw $iface set power_save off
To make these changes permanent add these to either /etc/rc.local or /etc/rc.d/rc.local, depending on your system.
Using NetworkManager
Modify your NetworkManager config located at /etc/NetworkManager/conf.d/wifi-powersave-off.conf, and add the following changes at the end of the file.
[connection]
wifi.powersave = 2
As a conservative shortcut execute the following command.
sudo cat <<DOC>>/etc/NetworkManager/conf.d/wifi-powersave-off.conf
[connection]
wifi.powersave = 2
DOC
Increase buffer size
Once you have NetworkManager tuned we are going to dab a bit with kernel level optimization.
Firstly, increase the buffer size. This is mostly significant older CPUs, and might just give you a fair boost.
sudo sysctl -w net.core.rmem_max=16777216
sudo sysctl -w net.core.wmem_max=16777216
sudo sysctl -w net.ipv4.tcp_rmem="4096 87380 16777216"
sudo sysctl -w net.ipv4.tcp_wmem="4096 87380 16777216"
TCP fast open, et al
A few more miscellaneous parameters for reduced latency.
sudo sysctl -w net.ipv4.tcp_fastopen=3
sudo sysctl -w net.ipv4.tcp_low_latency=1
sudo sysctl -w kernel.nmi_watchdog=0
sudo sysctl -w kernel.numa_balancing=0
Congestion Control
Linux comes with bbr as a congestion control mechanism, and it certain cases it performs much better than the default.
To check your available congestion control mechanisms run,
sysctl net.ipv4.tcp_available_congestion_control
The output should be similar to = reno cubic bbr.
In case bbr is missing add it using,
sudo modprobe tcp_bbr
echo "tcp_bbr" | sudo tee -a /etc/modules-load.d/bbr.conf
Now you can enable bbr, by setting the net.ipv4.tcp_congestion_control parameter.
sudo sysctl -w net.ipv4.tcp_congestion_control=bbr
Disable ASPM
WARNING: Execute ONLY if you understand the consequences. Take care.
You could disable ASPM for your network driver using (replace the [driver] placeholder’s with your actual network driver),
echo 'options [driver] disable_aspm=1' > /etc/modprobe.d/wifi.conf
sudo modprobe -r [driver]
sudo modprobe [driver]
You can find your driver using the following command,
lshw | grep -15 network | grep driver
Conlusion
Well this post was short! I do admit I took this down in a bit of flurry. While these were initially meant as way for me to keep track of the changes, i would be delighted if you benefit of this.