Guides

High iowait on Ubuntu: how to find the cause

In short

High iowait means the CPU sat idle while a disk request was still pending. Run iostat -x 1 to find the disk and pidstat -d 1 to find the process, then read /proc/pressure/io to see whether work was really stalled. A disk with rising r_await, w_await and aqu-sz is the usual cause.

The symptom

The load average is high, the CPUs look mostly idle, and top shows a large wa figure. Requests are slow, but no process is using much CPU.

Diagnose it in two commands

Install the tools on a stock Ubuntu or Debian host with sudo apt-get install -y sysstat. The first command names the disk, the second the process:

$ iostat -x 1 2
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          22.06    0.00    8.77    1.59    0.06   67.51

Device    r/s   rkB/s  r_await  w/s    wkB/s  w_await  aqu-sz  %util
vda     13.09  282.04     2.36  138.52 3731.59    1.59    0.26   2.61

$ pidstat -d 1 2
UID    PID   kB_rd/s   kB_wr/s kB_ccwr/s iodelay  Command

The second sample of iostat is the one that matters: the first line of output averages the time since boot. Read the r_await and w_await columns (milliseconds per request) with aqu-sz (the average queue) and %util. In pidstat -d, the process with the highest kB_rd/s or kB_wr/s, or a large iodelay, is the one waiting on the disk.

Then ask the kernel whether work really stalled:

$ cat /proc/pressure/io
some avg10=1.62 avg60=0.46 avg300=0.12 total=5825623114
full avg10=1.46 avg60=0.41 avg300=0.09 total=4430236826

some is the share of time at least one task waited for I/O, and full the share in which every non-idle task did. Low single figures are normal on a busy host. A full figure that stays high means nothing could make progress because of storage.

Causes and how to tell them apart

Cause How to tell Fix
One process doing heavy I/O (a backup, a re-index, a log burst) pidstat -d 1 shows one process with a large kB_rd/s or kB_wr/s Move the job off peak hours, or run it with ionice -c 3 so it yields to other work
The disk is at its limit r_await and w_await rise together with aqu-sz, and /proc/pressure/io full stays high Move to a larger or faster volume, or raise its provisioned IOPS and throughput
Swapping vmstat 1 shows non-zero si and so, and cat /proc/pressure/memory is high Add memory or run less on the host: the disk is a symptom
One slow or failing device One device has a high r_await or w_await with low throughput Check the volume’s health in your provider’s console, and replace it if it is failing

On NVMe drives and cloud volumes, which serve many requests at once, %util can read 100% without the device being saturated. Read it with the await and queue columns, never alone.

Fix it

For a single heavy job, lower its I/O priority while it runs, then schedule it away from busy hours:

$ sudo ionice -c 3 -p <pid>

For a saturated disk, the fix is capacity, not tuning: resize or re-type the volume, and re-run iostat -x 1 2 to confirm that r_await and w_await fall.

Stop it coming back

Alert on I/O pressure and disk latency rather than on iowait: iowait is idle CPU time while a request was pending, falls as you add cores, and says little about how long work waited. Keep backups and batch jobs on a schedule, and look at the busiest process in pidstat -d after any change in load.

What WatchTower15 shows

The agent reports each disk’s latency, busy share and queue depth, and the server’s Saturation charts show the pressure stall percentage and the tasks waiting on I/O. The built-in alarms Server I/O pressure is high (warning at 20%, critical at 50%) and Server disk latency is high (warning at 100 ms for five minutes) open on their own when a disk is the problem. See the Saturation charts and Alarms & alerting for the server rules.

Sources