When a Linux server stops scaling with packet rate, the usual cause is that all of the network interrupt work has collapsed onto one CPU: a single core pegged in softirq time while the other thirty-one idle, and packets dropping even though the box looks mostly idle in aggregate. This guide shows how to prove that from /proc/interrupts, /proc/softirqs and /proc/net/softnet_stat, then how to fix it by giving the NIC more receive queues and pinning each queue’s interrupt to its own CPU on the right NUMA node. It also covers RPS for single-queue NICs, the latency that interrupt coalescing costs you, and the far more common case where none of this is the answer.
What you’ll accomplish
- Prove from three independent counters whether one CPU is absorbing every network interrupt, before touching anything.
- Count and resize the NIC’s hardware receive queues with
ethtool -landethtool -L. - Pin each queue’s IRQ to a CPU on the NIC’s own NUMA node, and stop
irqbalancesilently undoing it. - Fall back to RPS and XPS when the hardware offers only one queue.
- Tell ring-buffer drops apart from backlog drops and NAPI time squeezes, so you turn the knob that matches the symptom.
Prerequisites
rootorsudoon the host that owns the NIC. This is host-level tuning: a container cannot do it, and inside a VM you are tuning the virtual NIC, not the physical one.ethtool,sysstatformpstat, andgawkfor hex arithmetic:apt install ethtool sysstat gawkordnf install ethtool sysstat gawk.- Any current kernel. The paths used here —
/proc/irq/<n>/,/sys/class/net/<iface>/queues/— have been stable for a decade. - A baseline: today’s packet rate, drop count and softirq CPU time. Without it you cannot tell whether a change helped.
- Honest caveats. Many drivers use kernel-managed interrupt vectors, and writing to
smp_affinityon those returns an error by design. Virtual NICs vary:virtio-netexposes real per-queue IRQs when the hypervisor gave it several, while some cloud NICs refuse affinity changes entirely.
How it works
A packet arriving on a multi-queue NIC is hashed by the card itself. Receive Side Scaling hashes the flow’s addresses and ports, indexes an indirection table, and drops the packet into one of several hardware receive queues. Each queue owns a distinct MSI-X vector with its own entry under /proc/irq/, and that entry’s affinity mask decides which CPU runs the handler — and therefore which CPU runs the NET_RX softirq where NAPI polls the queue and pushes packets up to a socket.
That chain is where the imbalance hides. RSS can spread traffic across eight queues and still buy you nothing if all eight IRQs point at CPU0 — the hardware fanned out, then the software funnelled it straight back in. Because most monitoring averages across cores, this reads as “the server is fine” right up until it isn’t.
Two properties of the affinity mask matter. /proc/irq/<n>/smp_affinity is a hexadecimal bitmask while /proc/irq/<n>/smp_affinity_list is the same thing as a CPU list — smp_affinity of 10 means CPU 4, whereas smp_affinity_list of 10 means CPU 10. And a mask may name several CPUs while the interrupt controller delivers to exactly one; /proc/irq/<n>/effective_affinity_list reports which. Pin to a single CPU and there is nothing to guess about.
NUMA is the other half. On a two-socket machine the NIC hangs off one socket’s PCIe root complex, and an interrupt handled on the other socket drags every descriptor and header across the interconnect. /sys/class/net/<iface>/device/numa_node names the NIC’s node and local_cpulist names the CPUs on it. The same reasoning that governs CPU pinning and NUMA alignment for VMs applies: keep the work next to the memory it touches.
Step-by-step
-
Prove the imbalance before you touch anything. Watch per-core softirq time under real load. The
%softcolumn is the one that matters.mpstat -P ALL 1 5Success signal: one row per CPU. If a single CPU shows
%softin the tens of percent while every other CPU is near zero, you have found the problem. If softirq time is already spread, stop here — the bottleneck is elsewhere and pinning will not help. -
Confirm it in the interrupt counters.
/proc/interruptsgives one row per IRQ and one column per CPU; the last column is the device name the driver registered.grep -E 'eth0|CPU0' /proc/interruptsSuccess signal: one row per NIC queue, named something like
eth0-TxRx-0througheth0-TxRx-7. Sample it twice a second apart; if every increment lands in the same CPU column, the IRQs are stacked. Driver naming varies — Intel usesi40e-eth0-TxRx-0, Mellanoxmlx5_comp0@pci:..., AWS ENAeth0-Tx-Rx-0— so adjust the pattern to what your file actually contains. -
Cross-check the softirq side. Interrupt counts tell you where the handler ran;
/proc/softirqstells you where the packet processing ran.grep -E 'NET_RX|NET_TX' /proc/softirqsSuccess signal: two rows of per-CPU counters. A hot
NET_RXcolumn matching the hot column in/proc/interruptsconfirms the diagnosis. Disagreement usually means RPS is already redistributing work, which changes what you should fix. -
Find out how many queues the NIC actually has. You cannot spread across queues that do not exist.
ethtool -l eth0Expected output:
Channel parameters for eth0: Pre-set maximums: RX: n/a TX: n/a Other: 1 Combined: 16 Current hardware settings: RX: n/a TX: n/a Other: 1 Combined: 4CombinedunderPre-set maximumsis the ceiling; the one underCurrent hardware settingsis live. A card reporting a maximum of1has no RSS to tune — skip to step 9. Some cards separateRXandTXinstead of usingCombined; tune whichever field is notn/a. -
Locate the NIC’s NUMA node and its local CPUs. Do this before choosing which CPUs to pin to.
cat /sys/class/net/eth0/device/numa_node cat /sys/class/net/eth0/device/local_cpulistSuccess signal: a node number such as
0and a CPU list such as0-15,32-47. Anuma_nodeof-1means the platform did not report locality — common on single-socket machines and in VMs — in which case ignore NUMA and pin to any CPUs. -
Set the queue count. One queue per CPU you intend to dedicate is the usual target. Do not exceed the number of CPUs on the NIC’s NUMA node.
sudo ethtool -L eth0 combined 8Success signal: the command returns silently and
ethtool -l eth0reportsCombined: 8under current settings. Expect the link to bounce on many drivers, and expect IRQ numbers to be reallocated — any affinity you set earlier is gone.Operation not supportedmeans the driver needs a module parameter at load time instead. -
Stop irqbalance from fighting you, without disabling it.
irqbalanceperiodically rewrites affinity masks, so a manual pin can survive for seconds and then quietly revert. The blunt fix is to stop the daemon, but it is also balancing storage and NVMe interrupts. Ban the specific NIC IRQs instead.for irq in $(grep -E 'eth0-(TxRx|Tx-Rx|rx)-' /proc/interrupts | cut -d: -f1 | tr -d ' '); do printf ' --banirq=%s' "$irq" done; echoThat prints the argument list. Put it in the daemon’s option file —
/etc/default/irqbalanceon Debian and Ubuntu (OPTIONS=),/etc/sysconfig/irqbalanceon the RHEL family (IRQBALANCE_ARGS=) — then restart it.sudo systemctl restart irqbalance systemctl show -p ExecStart irqbalanceSuccess signal:
ExecStartechoes the--banirqarguments you added. On hosts with many NICs,IRQBALANCE_BANNED_CPULISTscales better: it tells the daemon to leave a set of CPUs alone entirely. Keeping userspace off those same cores is a separate lever — see cgroup v2 resource control. -
Pin one queue IRQ per CPU. Write to
smp_affinity_list, notsmp_affinity, so you are writing CPU numbers rather than a bitmask.IFACE=eth0 # CPUs on the NIC's own NUMA node, taken from local_cpulist above CPUS=(0 1 2 3 4 5 6 7) i=0 for irq in $(grep -E "${IFACE}-(TxRx|Tx-Rx|rx)-" /proc/interrupts | cut -d: -f1 | tr -d ' '); do echo "${CPUS[$i]}" | sudo tee /proc/irq/${irq}/smp_affinity_list >/dev/null i=$(( (i + 1) % ${#CPUS[@]} )) doneVerify what actually took effect, which is not always what you wrote:
for irq in $(grep -E 'eth0-(TxRx|Tx-Rx|rx)-' /proc/interrupts | cut -d: -f1 | tr -d ' '); do printf 'irq %s requested=%s effective=%s\n' "$irq" \ "$(cat /proc/irq/$irq/smp_affinity_list)" \ "$(cat /proc/irq/$irq/effective_affinity_list 2>/dev/null)" doneSuccess signal: each IRQ maps to a distinct CPU and
effectivematchesrequested. A write that fails withInput/output errormeans the driver uses kernel-managed vectors — see Troubleshooting. -
If the NIC has only one queue, use RPS instead. Receive Packet Steering hashes in software after the interrupt and hands packets to other CPUs’ backlogs. It costs an inter-processor interrupt per batch, so it is a fallback, not a first choice.
rps_cpustakes a hexadecimal mask, not a list.# spread to CPUs 1-7 on an 8-core box, leaving CPU0 for the interrupt itself echo fe | sudo tee /sys/class/net/eth0/queues/rx-0/rps_cpusSuccess signal: reading the file back returns
fe. Pair it with Receive Flow Steering so packets follow the CPU the application runs on, and set XPS so transmits use the queue matching the sending CPU:sudo sysctl -w net.core.rps_sock_flow_entries=32768 echo 32768 | sudo tee /sys/class/net/eth0/queues/rx-0/rps_flow_cnt echo 1 | sudo tee /sys/class/net/eth0/queues/tx-0/xps_cpus -
Adjust coalescing last, and only if you have a reason. Coalescing makes the NIC wait before raising an interrupt, trading latency for fewer interrupts and lower CPU.
ethtool -c eth0Success signal: a block listing
Adaptive RX: on TX: on, thenrx-usecs,rx-framesand their transmit counterparts. If adaptive mode is on, the driver is already varying these with load; usually leave it alone. To raise the holdoff manually:sudo ethtool -C eth0 adaptive-rx off rx-usecs 100 rx-frames 64Every microsecond of
rx-usecsis added latency for a packet arriving just after the timer resets. On a throughput-bound batch pipeline that is a fine trade; on a latency-sensitive RPC service it is exactly the wrong one. Many drivers support only a subset of these fields and returnOperation not supportedfor the rest. -
Make it survive a reboot. IRQ numbers are allocated when the driver brings the interface up, so persistence means re-running the pinning, not writing a static file.
sudo tee /usr/local/sbin/nic-irq-affinity.sh >/dev/null <<'EOF' #!/bin/bash # re-pin NIC queue IRQs; IRQ numbers change on every driver load IFACE=eth0 CPUS=(0 1 2 3 4 5 6 7) i=0 for irq in $(grep -E "${IFACE}-(TxRx|Tx-Rx|rx)-" /proc/interrupts | cut -d: -f1 | tr -d ' '); do echo "${CPUS[$i]}" > /proc/irq/${irq}/smp_affinity_list i=$(( (i + 1) % ${#CPUS[@]} )) done EOF sudo chmod 755 /usr/local/sbin/nic-irq-affinity.shWire it to a
systemdoneshot ordered after the network comes up, and re-run it any time you change the queue count withethtool -L.
Validate it works
Re-run the same three measurements under the same load, and compare against the baseline you took in step 1.
mpstat -P ALL 1 5
Expected: %soft now appears on several CPUs at a fraction of the previous peak, with no single core dominating.
Read the software-side counters. In /proc/net/softnet_stat there is one hexadecimal line per CPU: column 1 is packets processed, column 2 is packets dropped because the backlog was full, and column 3 is time_squeeze — how often NAPI exhausted its budget with work still pending.
gawk '{printf "cpu%-3d processed=%d dropped=%d squeezed=%d\n", NR-1, strtonum("0x"$1), strtonum("0x"$2), strtonum("0x"$3)}' /proc/net/softnet_stat
Expected: processed spread across CPUs rather than concentrated on one, dropped static, and time_squeeze growing slowly or not at all. Then the hardware side, where the driver reports what the card itself saw:
ethtool -S eth0 | grep -Ei 'drop|miss|err|no_buf'
Expected: counters like rx_missed_errors, rx_no_buffer_count or rx_dropped holding steady. Finish with the protocol counters, where TcpExtTCPBacklogDrop and UdpRcvbufErrors should be stable (netstat -s prints the same information in prose):
nstat -az | grep -Ei 'drop|error|prune'
The decision path below maps each of these symptoms onto the one knob that addresses it.
Troubleshooting
- Writing to
smp_affinity_listreturnsInput/output error. The driver requested kernel-managed interrupt vectors, and the kernel spread them across CPUs itself at probe time. This is not a permissions problem andsudowill not help. Read/proc/irq/<n>/effective_affinity_list: usually it is already distributed, because the kernel did by design the job you were about to do by hand. - The pinning reverted a few seconds later.
irqbalancerewrote it. Confirm your--banirqarguments are in the running command line viasystemctl show -p ExecStart irqbalance. The common mistakes are editing the option file without restarting the daemon, and banning IRQ numbers from before anethtool -Lreallocated them. - Queues are pinned correctly but one CPU is still hot. RSS is hashing your traffic into a single queue: one large flow, encapsulated traffic whose outer headers repeat for every inner flow (GRE, and VXLAN on cards that do not parse inner headers), or a hash covering addresses only. Check with
ethtool -n eth0 rx-flow-hash udp4; if ports are absent, add them withethtool -N eth0 rx-flow-hash udp4 sdfn, and inspect the indirection table withethtool -x eth0. - Drops continue with every CPU idle. The CPUs were never the constraint. Rising
rx_no_buffer_countorrx_missed_errorsinethtool -Smeans descriptors ran out between polls: grow the ring withethtool -G eth0 rx 4096, or reduce the holdoff so the card is serviced sooner. Risingtime_squeezemeans the opposite — NAPI is cut off mid-poll — andnet.core.netdev_budget(default 300) plusnet.core.netdev_budget_usecsare the knobs. A rising column 2 points atnet.core.netdev_max_backlog. - Latency got worse after the change. Almost always coalescing. Check
ethtool -c eth0for a largerx-usecsand either lower it or turnadaptive-rx on. If you changed coalescing and pinning in the same window, revert the coalescing first — pinning does not add latency, holdoff timers do.
When this is the wrong approach
Most servers should never do any of this. Modern drivers allocate one queue per CPU and let the kernel place the vectors, and irqbalance handles the rest competently. If your server is not measurably saturating a CPU in softirq time, hand-pinning IRQs buys nothing and costs you a brittle boot-time script that stops matching reality the first time the NIC is replaced or the driver renumbers its vectors.
Inside a VM you are tuning the guest’s virtual NIC, which can help when the hypervisor gave it several queues — but the physical NIC’s queues belong to the host. In a container it is worse: /proc/irq is not yours to write, and the fix belongs on the node.
If the traffic is one heavy flow, RSS cannot help by construction: a single 5-tuple hashes to one queue, and splitting it would reorder packets. Scale the number of connections instead. And if the box drops packets because the application is not reading its sockets fast enough, the drops land in UdpRcvbufErrors or TcpExtTCPBacklogDrop rather than in the driver, and no interrupt tuning will touch them.
Where this pays off is a narrow band: bare-metal hosts pushing millions of packets per second — routers, load balancers, packet capture, high-rate telemetry ingest — where a single core saturating in softirq time is the measured ceiling. The kernel’s own Scaling in the Linux Networking Stack document is the reference for these mechanisms and is worth reading before you commit to a layout.
If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.