Your monitoring fires cpu_iowait > 30% for fifteen minutes and the engineer on rotation is staring at a host that “feels slow” with no obvious culprit. The temptation is to attribute everything to a saturated disk and order faster storage. That is sometimes the right answer and very often not. This runbook walks the actual decomposition — what iowait means, what it does not mean, and how to identify the process and the operation pattern actually causing the wait, in under ten minutes.
How to verify
# Per-device utilization and queue depth
iostat -xz 1 5
# Tasks currently blocked on I/O (D state)
ps -eo state,pid,comm | awk '$1=="D"'
# Per-process disk I/O attribution
sudo iotop -boPa -d 2 -n 30
# Block-layer latency histogram (bcc tools)
sudo biolatency-bpfcc 10 1
# Per-PID per-file I/O over a window
sudo biosnoop-bpfcc 30 > /var/tmp/biosnoop.log
If iostat shows %util near 100 on one device with growing await, the device is saturated. If %util is moderate but you still see high iowait, the wait is per-task — a small number of processes are blocking on slow individual operations, not the device.
What’s happening
iowait is the share of CPU time during which a CPU was idle AND at least one task on that CPU was waiting on I/O. It is a CPU accounting metric, not a disk metric. Three operational misreadings of this number are responsible for nearly every misdiagnosis:
- High iowait does not mean the disk is overloaded. It means the CPU had nothing else to do and was waiting on I/O. A single blocked task on an otherwise idle host can produce 100% iowait on that CPU. The fix is in the application, not the disk.
- Low iowait does not mean disk is fine. If the CPUs are busy with other runnable work, blocked-on-I/O tasks are no longer counted as iowait — they show up as latency on the affected application but not in the CPU breakdown.
- iowait is per-CPU, not per-host. A
topsummary showing 5% iowait can hide one CPU at 80% iowait pinning a critical thread. Always inspect per-CPU withmpstat -P ALL 1.
The diagnosis decomposes along two axes:
- Device saturation vs per-task latency.
iostat -xz%utiland average queue depth answer this. If%utilis near 100, the device is the bottleneck. Otherwise, individual operations are slow but the device has headroom. - Synchronous vs asynchronous I/O pattern.
biolatencyandbiosnoopanswer this. A workload doing fsync every few writes will look slow even on a fast NVMe; a workload reading random 4K blocks from spinning rust will look slow because seek times dominate.
The procedure
-
Confirm the metric is real, per-CPU. A host-level average can mislead:
mpstat -P ALL 2 5Look at the
%iowaitcolumn per CPU. If only one or two cores show high iowait, the workload is single-threaded or pinned. The fix lies in identifying that one task. -
Decide device vs task. Run
iostat -xz 1 5and read three columns:iostat -xz 1 5%util— fraction of wallclock time the device was busy. Near 100 = saturated.avgqu-sz(oraqu-szon newer iostat) — average queue length. Above 1.0 sustained = the device cannot keep up.await— average ms per request, end-to-end. Ifawaitis much greater thansvctm(or the device’s known service time), requests are queuing.
If
%utilnear 100, jump to step 4. Otherwise continue to step 3. -
Attribute to a process. With
%utilmoderate but iowait high, a single slow task is blocking:sudo iotop -boPa -d 2 -n 30 > /var/tmp/iotop.log awk 'NR>7 {print $4, $5, $9, $10, $12}' /var/tmp/iotop.log | sort -k2 -n | tail -20Note the PIDs that show high IO> column or DISK READ/WRITE. Cross-check with:
for pid in $(ps -eo state,pid | awk '$1=="D" {print $2}'); do echo "PID $pid: $(cat /proc/$pid/comm 2>/dev/null) — stack:" sudo cat /proc/$pid/stack 2>/dev/null | head -3 doneThe kernel stack of a D-state task tells you the syscall it’s blocked in. Common patterns:
wait_on_buffer(synchronous read),do_get_write_access(journal commit),io_schedule(generic block wait). -
Characterize the I/O pattern. Run biolatency for 30 seconds on the busy device:
sudo biolatency-bpfcc -D 30 1A healthy NVMe shows a tight distribution around 100-500us. If the histogram has a long tail past 10ms, individual operations are slow — either small random IOPs hitting saturation, or large sequential operations contending. Then run biosnoop to see which files:
sudo biosnoop-bpfcc 30 | awk '$7+0 > 10 {print}' | head -50Operations with latency over 10ms are the laggards. Note the COMM and FILE columns.
-
Apply the targeted fix. Map findings to one of these patterns:
- Device truly saturated.
%util100, queue depth growing, biolatency spread. Provision more iops or move the hot dataset to faster storage. If on EBS, check that you’re not hitting per-volume IOPS limits —aws ec2 describe-volumesthen compareVolumeType/Iopsagainstiostattotals. - Single-task fsync storm. D-state task in
do_get_write_access. Application is fsync-per-write — batch writes or change durability profile. Common on databases configured withinnodb_flush_log_at_trx_commit=1plus high commit rate; consider group commit tuning. - Read amplification from page cache eviction. Add memory or pin a working set with
vmtouch -dl /path/to/hot/files. Checkcat /proc/meminfo | grep -E 'Cached|Dirty'— if Cached is tiny relative to data size, evictions are forcing rereads. - Journal commit pinning.
iostat -xshows writes on the journal device alongside read latency on the data device. Switch ext4 todata=writeback,noatimeif the application tolerates the durability change, or move the journal to a separate device. - Co-tenant noisy neighbor on shared block storage. Latency unrelated to local load; biolatency tail despite low local IOPS. Open a ticket with the IaaS provider; on AWS, check CloudWatch
VolumeQueueLengthfor the volume.
- Device truly saturated.
Common pitfalls
- Buying faster disks before measuring. If the iowait is one blocked thread doing 100 fsyncs/sec, faster disks help less than batching writes. Measure first.
- Reading host-average iowait. A 4% host average can hide a pinned thread at 90% on one core. Always
mpstat -P ALL. - Trusting iotop on a tickless kernel. iotop relies on task accounting that is unreliable for short-lived tasks. For short bursts, prefer biosnoop.
- Confusing await with svctm.
awaitincludes queue time;svctmis service time only. On modern multi-queue block devicessvctmis approximated and unreliable; use biolatency for actual service time. - Setting
vm.dirty_ratiolow to “smooth writes.” A lower ratio causes more frequent small writeback cycles, which can increase contention if the workload is bursty. Tune based on the actual write pattern, not a default recommendation.
Stack Harbor runs per-host biolatency baselines and tags any drift in the upper percentiles automatically — so an iowait alert arrives with the histogram already attached and the offending process already identified, not as a vague “disk is slow” page. See our managed operations service for the standing instrumentation layer.