Hashing Single-Queue NIC Interrupts
Principles
Receive Packet Steering (RPS) is introduced in Linux kernel 2.6.35. RPS uses software simulation to implement the functions provided by the multi-queue NIC. It balances the loads during data receiving in the multi-CPU system by distributing software interrupts to each CPU for processing without requiring hardware support, greatly improving network performance.
For a single-queue NIC, you can use RPS to distribute interrupts to each core for processing. This prevents software interrupts from being centralized to one core, preventing performance bottlenecks caused by too many software interrupts of the core.
Modification Method
Modify the NIC queue parameter RPS. This modification takes effect immediately without restarting the server.
Before the modification:
1 2 3 | /sys/class/net/eth0/queues/rx-0/rps_cpus 0 /sys/class/net/eth0/queues/rx-0/rps_flow_cnt 0 /proc/sys/net/core/rps_sock_flow_entries 0 |
Modification:
1 2 3 | #echo ff > /sys/class/net/eth0/queues/rx-0/rps_cpus # echo 4096 > /sys/class/net/eth0/queues/rx-0/rps_flow_cnt # echo 32768 > /proc/sys/net/core/rps_sock_flow_entries |
A single NIC is used as an example. ff corresponds to cores 0 to 7, indicating that software interrupts are distributed to cores 0 to 7. If there are multiple NICs, the value of ff must be changed. The expected maximum number of concurrent active connections is set to 32768, which is the recommended value of the Linux kernel.