Course contentsShow
← Linux
Lesson 1659 of 1,81914. Observability and Performance TroubleshootingFree lesson

Interrupt coalescing optimization

Balance between high interrupt rates and latency by tuning driver interrupt moderation settings.

In this lesson, you will learn how to fine-tune interrupt coalescing to strike an ideal balance between high-throughput packet processing and low-latency response times.

The Trade-off: Throughput vs. Latency

Modern high-speed network interfaces (NICs) can receive millions of packets per second. If the NIC triggers an interrupt for every single incoming packet, the CPU becomes overwhelmed by "interrupt storms," leading to massive context-switching overhead and reduced system performance.

To mitigate this, NIC drivers use Interrupt Coalescing (also known as interrupt moderation). This technique instructs the hardware to wait until a specific threshold of packets is received, or a maximum time interval has elapsed, before triggering a hardware interrupt to the CPU.

  • Aggressive Coalescing: High packet thresholds or long delays lead to high throughput and low CPU usage, but significantly increase latency because packets sit in the buffer waiting for the "batch" to be signaled.
  • Disabled Coalescing: Low or zero thresholds provide the lowest possible latency but risk saturating the CPU when traffic spikes, as every packet requires a kernel transition.

Tuning the Parameters

You can inspect and adjust these settings using ethtool. For example, to view current moderation settings:

ethtool -c eth0

If you see rx-usecs (the delay timer) set to 0, the NIC is likely in low-latency mode. To optimize for high throughput, you might increase the delay:

# Set Rx interrupt coalescing delay to 100 microseconds
sudo ethtool -C eth0 rx-usecs 100

Observing the Impact

While adjusting these parameters, you must monitor the impact on your system. You can observe the frequency of interrupts in real-time by monitoring /proc/interrupts. If you observe your SoftIRQ load (via top or mpstat) remains high despite increasing coalescing, you may be hitting the limits of your NIC's internal buffer or the memory bus. Conversely, if your application experiences "jitter" or high tail latency, your coalescing timers are likely too aggressive.

Key Takeaway: Interrupt coalescing is a performance lever where increasing timers improves throughput at the cost of latency; always profile your specific workload to find the optimal trade-off point for your NIC hardware.