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_wmem
values are set to the maximum buffer size:sysctl net.core.rmem_max
sysctl net.core.wmem_max
sysctl net.ipv4.tcp_rmem
sysctl net.ipv4.tcp_wmem
If any of these values are set to a lower value, you can increase them. For example, to increase the
net.core.rmem_max
value 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_max
andnet.core.wmem_max
values, and to 16MB for thenet.ipv4.tcp_rmem
andnet.ipv4.tcp_wmem
values, 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_max
andnet.core.wmem_max
values, and to 16MB for thenet.ipv4.tcp_rmem
andnet.ipv4.tcp_wmem
values. - Verify that the changes have been applied:
sysctl net.core.rmem_max
sysctl net.core.wmem_max
sysctl net.ipv4.tcp_rmem
sysctl net.ipv4.tcp_wmem
- Save the changes so that they are applied at boot time. You can add the
sysctl
commands to the/etc/sysctl.conf
file: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.conf
This will add the
sysctl
commands to the end of the/etc/sysctl.conf
file.
That’s it! You have tuned the network stack buffers size to increase the networking performance of your Linux system.