Starting a Stress Test to improve performance, I reach some limits when the system was under intense fire up. By default the Linux network stack is not configured for high speed large file transfer across WAN links. This is done to save memory resources. You can easily tune Linux network stack by increasing network buffers size for high-speed networks that connect server systems to handle more network packets.

The default maximum Linux TCP buffer sizes are way too small. TCP memory is calculated automatically based on system memory; you can find the actual values by typing the following commands:

The default and maximum amount for the receive socket memory:

The default and maximum amount for the send socket memory:

The maximum amount of option memory buffers:

 Tuning the Values

Set the max OS send buffer size (wmem) and receive buffer size (rmem) to 12 MB for queues on all protocols. In other words set the amount of memory that is allocated for each TCP socket when it is opened or created while transferring files:

WARNING! The default value of rmem_max and wmem_max is about 128 KB in most Linux distributions, which may be enough for a low-latency general purpose network environment or for apps such as DNS / Web server. However, if the latency is large, the default size might be too small. Please note that the following settings going to increase memory usage on your server.

Now, as root user…

You also need to set minimum size, initial size, and maximum size in bytes:

Turn on window scaling which can be an option to enlarge the transfer window:

Enable timestamps as defined in RFC1323:

Enable select acknowledgments:

By default, TCP saves various connection metrics in the route cache when the connection closes, so that connections established in the near future can use these to set initial conditions. Usually, this increases overall performance, but may sometimes cause performance degradation. If set, TCP will not cache metrics on closing connections.

Set maximum number of packets, queued on the INPUT side, when the interface receives packets faster than kernel can process them.

Now reload the changes:

Use tcpdump to view changes for eth0, eth1 or wlan0, or…

See the results, enjoy it!