This topic describes how to configure parameters related to the Receive Packet Steering (RPS) feature in the Linux operating system to optimize network packet processing and improve network performance and load balancing on multicore systems.
Parameter description
net.core.rps_sock_flow_entries
This parameter specifies the maximum number of flow table entries in the Linux kernel, that is, the number of network flows that can be tracked simultaneously. Increasing the value of this parameter can improve RPS performance, thereby enabling more efficient utilization of multiple CPU cores for processing network traffic. Each flow in the flow table corresponds to a network connection. When a packet arrives, the kernel determines the corresponding flow based on the source address, destination address, protocol, and other information of the packet, and then dispatches the packet to the CPU core associated with that flow for processing.
In this practice, rps_cpus refers to the /sys/class/net/<interface>/queues/rx-<queue>/rps_cpus parameter, which specifies the CPU cores that process network flow packets from the specified queue queues of a single network interface. By configuring this argument, you can limit the number of CPU cores involved in RPS processing, thereby improving system performance.
In this practice, rps_flow_cnt refers to the /sys/class/net/<interface>/queues/rx-<queue>/rps_flow_cnt parameter, which specifies the maximum number of flows that can be cached in the RPS queue on each CPU core, within the specified queues of a single network interface. By increasing the value of this parameter, more data packets can be distributed across multiple processing cores, thereby accelerating the processing of data packets.
Applicable scenario
- When the number of CPUs is much greater than the number of network interface queues, you can improve network performance by configuring the rps_sock_flow_entries parameter.
- When an ECS instance uses a virtual network interface (for example, veth), you can configure the rps_sock_flow_entries parameter to significantly improve network performance.
warning
- We recommend that you do not configure parameters related to the RPS feature for regular physical network interfaces, as this may increase inter-core interrupt overhead and degrade performance.
- RFS depends on RPS. RPS is disabled by default, and you need to enable RPS for RFS-related configuration to take effect. When you configure the CPU list for RPS, we recommend that you select CPUs within the same NUMA domain as the interrupt CPU, and do not select CPUs that are already heavily loaded.
Procedure
Configuration by using the proc interface
Configuration by using a file
You can use this method to temporarily modify the parameter values while the operating system is running. You need to configure the parameters again after the instance restarts.
- Execute the following commands to view the parameter values.
- View the value of the rps_sock_flow_entries parameter.
-
- View the value of the rps_cpus parameter.
-
- View the value of the rps_flow_cnt parameter.
-
- Execute the following command to configure parameters.
- Configure the rps_sock_flow_entries parameter.
tip
We recommend that you set this parameter to 32768. You can also modify the parameter based on your actual needs.
- Configure the rps_cpus parameter.
tip
This command is executed to specify that all available CPU cores are used for processing when the eth0 network interface receives data packets. Replace eth0 with the actual name of the network interface.
- Configure the rps_flow_cnt parameter.
tip
In this practice, the number of CPU cores for the instance is 8, and the name of the network interface is eth0.
- Replace 4096 with the value of rps_sock_flow_entries divided by the number of CPU cores.
- Replace eth0 with the actual name of the network interface.
You can use this method to permanently modify the parameter values while the operating system is running. You do not need to configure the parameters again after the instance restarts.
- Execute the following commands to view the parameter values.
- View the value of the net.core.rps_sock_flow_entries parameter.
-
- Modify values of RPS-related parameters.
- Execute the following command to create the /etc/sysctl.d/rps.conf file.
- Press the i key to enter edit mode, and add the following content to the configuration file.
- Press the Esc key to exit edit mode, enter :wq, and then press Enter to save and exit the file.
- Execute the following command to create the /etc/sysfs-ng.d/rps.conf file.
- Press the i key to enter edit mode, and add the following content to the configuration file.
tip
In this practice, the number of CPU cores for the instance is 8, and the name of the network interface is eth0.
- Replace 4096 with the value of rps_sock_flow_entries divided by the number of CPU cores.
- Replace eth0 with the actual name of the network interface.
- Press the Esc key to exit edit mode, enter :wq, and then press Enter to save and exit the file.
- Execute the following command to create the /etc/sysctl.d/rps.conf file.
- Press the i key to enter edit mode, and add the following content to the configuration file.
- Press the Esc key to exit edit mode, enter :wq, and then press Enter to save and exit the file.
- Execute the following command to create the /etc/sysfs.d/rps.conf file.
- Press the i key to enter edit mode, and add the following content to the configuration file.
tip
In this practice, the number of CPU cores for the instance is 8, and the name of the network interface is eth0.
- Replace 4096 with the value of rps_sock_flow_entries divided by the number of CPU cores.
- Replace eth0 with the actual name of the network interface.
- Press the Esc key to exit edit mode, enter :wq, and then press Enter to save and exit the file.
- Execute the following command to restart the instance for the configuration to take effect.