Linux: Configuring RX POLLING (NAPI)
In Linux, Receive Side Scaling (RSS) and Network Adapter Poll Mode (NAPI) are two techniques that can be used to improve the performance of network I/O on multi-core systems. NAPI, in particular, allows for more efficient handling of network traffic by reducing the overhead associated with interrupt handling.
To configure NAPI, you can follow these steps:
- Identify the network interface that you want to configure. You can do this by running the
ifconfigcommand, which will display a list of all network interfaces that are currently available on the system. - Check whether NAPI is currently enabled for the network interface. You can do this by running the
ethtoolcommand with the name of the network interface as an argument. For example:sudo ethtool -k eth0This will display a list of offload options that are currently enabled for the interface. Look for the
rx-usecsoption, which controls the polling interval for NAPI. - Enable NAPI by setting the
rx-usecsoption to a value of 0. This will cause the network driver to use NAPI instead of interrupt-driven I/O. You can set this option using theethtoolcommand with the-Coption. For example:sudo ethtool -C eth0 rx-usecs 0Note that not all network drivers support NAPI, so this option may not be available for all interfaces.
- Verify that NAPI is working by monitoring the interrupt rate for the network interface. You can do this using the
sarcommand, which is part of thesysstatpackage. For example:sudo sar -n DEV 1This will display a real-time view of network statistics, including the interrupt rate for each network interface. Look for a decrease in the interrupt rate for the interface that you configured with NAPI.
