Linux Tune Network Stack (Buffers Size) To Increase Networking Performance
The networking performance of a Linux system can be improved by tuning the network stack buffers sizes. The buffer sizes can be adjusted using the sysctl command.
Here are the steps to tune the network stack buffers size:
- Open a terminal or shell prompt on your Linux system.
- Verify that the
net.core.rmem_max,net.core.wmem_max,net.ipv4.tcp_rmem, andnet.ipv4.tcp_wmemvalues are set to the maximum buffer size:sysctl net.core.rmem_maxrnsysctl net.core.wmem_maxrnsysctl net.ipv4.tcp_rmemrnsysctl net.ipv4.tcp_wmemIf any of these values are set to a lower value, you can increase them. For example, to increase the
net.core.rmem_maxvalue to 16MB, you can run:sysctl -w net.core.rmem_max=16777216 - Set the minimum buffer size for the network stack. The minimum buffer size is set to the maximum buffer size multiplied by the number of buffers. For example, to set the minimum buffer size to 32MB for the
net.core.rmem_maxandnet.core.wmem_maxvalues, and to 16MB for thenet.ipv4.tcp_rmemandnet.ipv4.tcp_wmemvalues, you can run:sysctl -w net.core.rmem_max=33554432 sysctl -w net.core.wmem_max=33554432 sysctl -w net.ipv4.tcp_rmem="16384 33554432 33554432" sysctl -w net.ipv4.tcp_wmem="16384 33554432 33554432"This will set the minimum buffer size to 32MB for the
net.core.rmem_maxandnet.core.wmem_maxvalues, and to 16MB for thenet.ipv4.tcp_rmemandnet.ipv4.tcp_wmemvalues. - Verify that the changes have been applied:
sysctl net.core.rmem_maxrnsysctl net.core.wmem_maxrnsysctl net.ipv4.tcp_rmemrnsysctl net.ipv4.tcp_wmem - Save the changes so that they are applied at boot time. You can add the
sysctlcommands to the/etc/sysctl.conffile:echo "net.core.rmem_max = 33554432" >> /etc/sysctl.conf echo "net.core.wmem_max = 33554432" >> /etc/sysctl.conf echo "net.ipv4.tcp_rmem = 16384 33554432 33554432" >> /etc/sysctl.conf echo "net.ipv4.tcp_wmem = 16384 33554432 33554432" >> /etc/sysctl.confThis will add the
sysctlcommands to the end of the/etc/sysctl.conffile.
