Lesson 6 of 9 · 24m
Storage and Network I/O: Queues, Latency, and Retries
Using iostat, blktrace concepts, and network counters to distinguish slow devices from saturated pipelines.
I/O incidents rarely announce themselves honestly. The application says requests are slow, CPU looks low, memory looks adequate, and the real story is a disk queue full of tiny writes or a network path retransmitting its way through congestion. With I/O, the critical mental shift is to think in queues: latency is service time plus waiting time.
iostat is the first stop
iostat -xz 1 5The important columns are more subtle than %util:
r/s w/s rkB/s wkB/s await aqu-sz %util
20 850 320 15400 18.2 4.9 96.4await is average time per I/O including queueing. aqu-sz is average queue depth. %util means the device had work outstanding, not that it was the bottleneck in the way people assume — especially on RAID, NVMe, and virtualized storage where parallelism hides inside the device.
A useful rule: compare observed latency with the device's expected service time. If an SSD normally serves writes in under a millisecond and await is 40 ms, most of that is queueing or downstream contention.
Filesystem behavior matters
Databases and write-heavy services are often hurt less by raw throughput than by flush patterns. Journaling, writeback, fsync frequency, and RAID write policy can dominate.
Watch dirty and writeback memory:
grep -E 'Dirty|Writeback' /proc/meminfoA burst of dirty pages followed by a latency spike often means the kernel is flushing buffered writes. Applications that fsync then wait behind a large flush even though their own write volume is small.
Network latency is not bandwidth
A link can be 20% utilized and still miserable because of packet loss, bufferbloat, or a single saturated CPU core handling interrupts. Basic evidence:
sar -n DEV,TCP,ETCP 1 5
ss -tin
ip -s link show eth0Look at retransmits, drops, overruns, and TCP round-trip times. retrans: in ss -tin tells you whether a flow is repeatedly resending. Interface drops can mean ring buffers or IRQ processing cannot keep up even when bandwidth appears modest.
Correlate application waits with kernel evidence
Slow disk or network only matters if the application waits on it. strace can answer narrow questions, but use it carefully:
sudo strace -c -p 2417 -fA syscall summary showing most time in fsync or read points to storage; time in recvfrom or connect points downstream. Never leave full strace attached to a busy production process — its overhead can turn a degraded service into a dead one.
Field notes
%utilnear 100 is not proof of saturation on modern parallel devices; queue depth and latency tell the real story.- Buffered writes make applications look fast until dirty-page writeback arrives; fsync-heavy workloads expose the truth.
- Retransmits are performance errors under the USE method, not harmless noise.
- On virtual machines, local device latency includes the hypervisor and remote storage fabric. Sometimes the evidence ends at the VM boundary.
Was this lesson helpful?