You need to enable JavaScript to run this app.
Elastic Compute Service

Elastic Compute Service

Copy page
Download PDF
Images
Configuring CPU affinity for IRQ of network interface in Linux operating system
Copy page
Download PDF
Configuring CPU affinity for IRQ of network interface in Linux operating system
This topic describes how to use the irqbalance-ng feature provided by the platform to automatically configure CPU affinity for the interrupt requests (IRQs) of physical network interfaces, thereby improving network performance.​
Applicable scenario​
In high network traffic scenarios, a large number of network interface IRQs may concentrate on a single CPU, causing delays in packet transmission and reception. irqbalance-ng operates in a periodic scanning mode, automatically checking and configuring the CPU affinity (via /proc/irq/{irq_id}/smp_affinity) of physical network interfaces. This prevents uneven CPU load when network interface IRQs are processed, thereby improving network performance.​
In scenarios where multiple Network Namespaces are configured, irqbalance-ng can automatically identify network interface information for each namespace and configure CPU affinity for the network interface IRQs.​
Usage notes​
The tool can only be installed and used in the images described in the following table.​
​
Image type​
Operating system version​
veLinux​
  • veLinux 1.0 64 bit​
  • veLinux 2.0 64 bit​
CentOS​
  • CentOS 7.x 64 bit​
  • CentOS 8.3 64 bit​
  • CentOS Stream 9.x 64 bit​
Ubuntu​
  • Ubuntu 18.04 64 bit​
  • Ubuntu 20.04 64 bit​
  • Ubuntu 22.04 64 bit​
  • Ubuntu 14.04 64 bit​
Debian​
  • 64-bit Debian 10​
  • Debian 12 64 bit​
Red Hat Enterprise Linux (RHEL)​
  • RHEL 7.8 64 bit​
  • RHEL 8.8 64 bit​
  • RHEL 9.2 64 bit​
  • RHEL 9.3 64 bit​
AlmaLinux​
  • AlmaLinux 8.x 64 bit​
  • AlmaLinux 9.x 64 bit​
​
Concepts​
​
Concept​
Description​
IRQ​
An interrupt request (IRQ) refers to an electrical signal actively sent by a device to the CPU, causing the CPU to stop its current task and process the received interrupt request.​
irqbalance​
A daemon used to help balance the CPU load generated by interrupts across all system CPUs.​
CPU affinity​
CPU affinity, also known as CPU binding, refers to the tendency of processes or IRQs to run on a specified CPU for an extended period without being migrated to other processors.​
NUMA​
Non-Uniform Memory Access (NUMA) is a memory architecture designed for multiprocessor computers. The memory access speed depends on the location of memory relative to the processor.​
Network Namespace​
A method provided by Linux for isolating system-wide resources. The method works by placing global resources of the system into different namespaces to achieve isolation. Programs in different namespaces can have their own independent set of system resources.​
​
Procedure​
Install irqbalance-ng​
You can log in to the target Linux instance and install the irqbalance-ng tool for the corresponding operating system.​
​
veLinux
CentOS
Debian
Ubuntu
Red Hat/AlmaLinux
​
  1. Execute the following command to configure the extra-tools software repository for the image.​
  • ​
    veLinux 1.0
    veLinux 2.0
    ​
    ​
    echo 'deb http://mirrors.ivolces.com/extra-tools/velinux/ orion main' >> /etc/apt/sources.list.d/extra-tools.list​
    wget -O - http://mirrors.ivolces.com/extra-tools/velinux/GPG-KEY-system | apt-key add -​
    ​
    ​
  1. Execute the following command to update the software repository information.​
  • ​
    apt-get update​
    ​
  1. Execute the following command to install irqbalance-ng.​
  • ​
    apt-get install irqbalance-ng​
    ​
​
Manage irqbalance-ng​
View the running status​
  1. Execute the following command to check whether irqbalance-ng is running as expected.​
  • ​
    systemctl status irqbalance-ng.service​
    ​
  • ​​​
Configure rules for running the tool​
You can modify the configuration file of irqbalance-ng to adjust settings such as the interval at which irqbalance-ng checks or adjusts CPU affinity for network interface IRQs, and the list of CPUs that handle network interface IRQs.​
  1. Execute the following command to edit the configuration file.​
  • ​
    vim /etc/default/irqbalance-ng​
    ​
  1. Press the i key to enter edit mode, and modify the irqbalance-ng configuration based on your needs.​
  • ​​​
  • Parameter description​
  • ​
    Parameter​​
    Description​
    Sample value​
    debug​
    The level of logs printed by the irqbalance-ng service. Valid values:​
    • 0: Logs of the error level are printed.​
    • 1: Logs of the info and error levels are printed. This is the default value.​
    • 2: Logs of the debug, info, and error levels are printed.​
    tip​
    The storage path for irqbalance-ng logs is /var/log/irqbalance-ng.log.​
    1​
    distinguish​
    The default setting. Do not modify the setting.​
    1​
    peroid​
    The interval (in seconds) at which irqbalance-ng checks or adjusts CPU affinity for network interface IRQs. The default value is 60.​
    60​
    cpu_lists​
    The CPUs specified to handle network interface IRQs. The default value is "", which specifies all CPUs. You can pass in multiple CPU IDs, and use commas (,) to separate them. You can use - to pass in a range of consecutive CPU IDs.​
    tip​
    You can execute the lscpu, numactl --hardware, or lshw command to view the CPU IDs. In the following figure, the lscpu command is used as an example. 0-7 indicates that the IDs of the CPUs are 0, 1, 2, 3, 4, 5, 6, and 7.​
    ​​​
    "1,4,5,10-15,20"​
    lib_path​
    The path to library files when you use the installation package to install the tool. We recommend that you do not modify the path.​
    -​
    net_path​
    The path to files related to network interfaces in the image. We recommend that you do not modify the path.​
    -​
    cpu_path​
    The path to the CPU device file in the image. We recommend that you do not modify the path.​
    -​
    numa_path​
    The path to the NUMA file in the image. We recommend that you do not modify the path.​
    -​
    ​
  1. Press Esc, enter :wq, and then press Enter to save the modifications and close the file.​
  1. After you modify the file, execute the following command to restart irqbalance-ng for the modifications to take effect.​
  • ​
    systemctl restart irqbalance-ng​
    ​
  1. You can execute the following command to view the binding information between IRQs and CPUs.​
This command retrieves IRQ information from /proc/interrupts and uses cat /proc/irq/$i/smp_affinity_list to configure or read the CPU affinity of IRQs. You can adjust the command based on your needs.​
  • ​
    for i in `cat /proc/interrupts | grep -E "input|output" | awk -F ' ' '{print $1}' | awk -F ':' '{print $1}'` ;do echo "irq_"$i ":" `cat /proc/irq/$i/smp_affinity_list` ;done​
    ​
  • ​​​
Stop irqbalance-ng​
You can execute the following command to stop periodic CPU affinity configuration for IRQs performed by irqbalance-ng.​
​
systemctl stop irqbalance-ng.service​
​
You can also execute the following command to disable irqbalance-ng from starting automatically when the instance starts.​
​
systemctl disable irqbalance-ng.service​
​
Uninstall irqbalance-ng​
  • CentOS/AlmaLinux/RHEL​
  • ​
    yum remove irqbalance-ng​
    ​
  • Debian/Ubuntu​
  • ​
    apt-get remove --purge irqbalance-ng​
    ​
​
Last updated: 2026.07.22 18:39:13