Network tunning¶
In certain use cases, the system requires tuning to effectively handle a high volume of packets, with the primary goal being to prevent packet drops. This guide provides an overview of the overall concept and suggests actions that can be taken. Before digging into network fine-tuning, it’s crucial to have a clear understanding of your actions. Below, we’ve listed some valuable sources of knowledge to help you get started
References
Warning
Fine-tuning Linux parameters is a tricky task and can lead to unexpected results, such as other applications becoming less responsive. Generally speaking, it’s better to use load balancing and have more than one module to handle the throughput.
How Linux is handling packets¶
In a brief overview, the network operates as follows:
Incoming packets arrive on the network card.
These packets are initially stored in the network card’s buffer.
Once the network card’s configuration conditions are met (either based on maximum time or the maximum packet limit), it sends an interrupt request (IRQ) signal to the kernel.
The kernel interrupts its ongoing tasks and retrieves the packets from the network card’s buffer.
The kernel stores these network packets in a local (kernel) buffer.
The kernel uses software interrupts (IRQ) to notify the application of network packets availability.
What can be wrong ?¶
Diagnose step 1 : Check the dropping stats¶
If the application is unable to retrieve packets from the kernel buffer quickly enough, it can lead to dropped messages because the kernel buffer becomes full. The CLI tools netstat can help identifying this case (example for UDP packets):
netstat -suna
IcmpMsg:
InType3: 155
InType8: 472
OutType0: 472
OutType3: 332
OutType8: 137
Udp:
32712 packets received
180 packets to unknown port received
19143 packet receive errors
5892 packets sent
19143 receive buffer errors
0 send buffer errors
IgnoredMulti: 11651
Field |
Description |
---|---|
Packet receive errors |
The number of invalid received UDP datagrams |
Receive buffer errors |
The number of packet dropped because the buffer encounter an error (like beeing full) |
Fine tune solution 1 : Change buffer parameters¶
One easy way to handle large throughput in burst can be to increase the size of the buffer, this can be done in the sysctl.conf
file
net.core.wmem_default=104857600
net.core.rmem_max=104857600
net.core.wmem_max=104857600
Note
See Kernel configuration explained for meaning of each fields
Fine tune solution 2 : Change buffer parameters¶
You have the option to adjust the number of packets processed per interruption. The default value is typically set to 300 packets per interruption. In cases you have lots of small packets, such as SNMP-TRAP, increasing the number of packets processed per interruption can result in improved performance
net.core.wmem_default=600