Disk and I/O bottlenecks

Advanced · 18 min

Read iostat -x correctly, see why %util and iowait mislead on modern storage, find the process doing the I/O, and know when the I/O scheduler matters.

Before thisThe first sixty seconds on a slow serverBlock devices and partitionsProcesses through /proc

BashLab · 18 min

Disk and I/O bottlenecks

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by BashLabReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • Storage has three numbers that matter: operations per second, throughput, and latency. An application usually feels latency first.
  • In `iostat -x`, `r_await` and `w_await` are average milliseconds per request including time queued, and `aqu-sz` is the average queue length. Rising await with a growing queue means saturation.
  • `%util` is the share of time a request was in flight. The iostat man page warns it does not reflect the limits of devices that serve requests in parallel, such as SSDs and RAID, so 100% on an NVMe drive is not necessarily full.
  • `%iowait` is CPU idle time while disk I/O is outstanding. It is a CPU state, not a disk measurement, and it can fall when the disk gets worse.
  • `pidstat -d 1` or `iotop` names the processes doing I/O. D-state processes in `ps` are the ones waiting on it.
  • The I/O scheduler in `/sys/block/<dev>/queue/scheduler` rarely needs changing. Fast NVMe devices usually run with `none`.

Fast CPUs, slow disks

A database query that takes 2 ms with its data in memory can take 200 ms when it has to wait for storage. CPUs work in nanoseconds. A network SSD works in hundreds of microseconds to milliseconds, and a spinning disk in several milliseconds per random read. When the first-sixty-seconds checklist shows wa in vmstat or blocked tasks in b, storage is the suspect, and the question becomes how to prove it.

Three numbers, not one

Storage performance has three dimensions:

  • IOPS: operations per second (r/s, w/s).
  • Throughput: bytes per second (rkB/s, wkB/s).
  • Latency: how long each operation takes (r_await, w_await).

They trade off. A backup job doing large sequential writes can max out throughput with few operations. A database doing 4 KiB random reads can max out IOPS at low throughput. Your application usually feels latency. Think of a motorway toll plaza: cars per hour, people per hour and minutes spent queuing are related but different. A plaza can move many cars per hour while each driver still waits too long.

Reading iostat -x

iostat -xz 1 prints one line per active device per second. From the iostat man page:

  • r_await / w_await: “the average time (in milliseconds) for read requests issued to the device to be served”, including time in the queue and time being served.
  • aqu-sz: “the average queue length of the requests that were issued to the device”. Older versions called it avgqu-sz.
  • %util: “percentage of elapsed time during which I/O requests were issued to the device”.
  • rareq-sz / wareq-sz: average request size in KiB, which tells you whether the workload is small random I/O or large sequential I/O.

The three are linked. Average queue length is roughly the request rate times the time each request spends in the system. At 2,000 requests per second and 5 ms each, about 10 requests are in flight on average. If the rate stays the same and await rises to 40 ms, the queue grows to about 80. That arithmetic is mine, from Little’s law, not a figure from the man page. It is why rising await together with rising aqu-sz at a steady request rate is the clearest sign of saturation.

Two numbers that mislead

%util made sense when a disk had one head that served one request at a time. Busy 100% of the time meant full. The iostat man page now warns: “for devices serving requests in parallel, such as RAID arrays and modern SSDs, this number does not reflect their performance limits.” An NVMe drive can show 100% while serving a fraction of what it is capable of. Use await and queue length to judge saturation, and %util only for single-queue devices.

%iowait sounds like a disk metric. The mpstat man page defines it as the percentage of time the CPUs “were idle during which the system had an outstanding disk I/O request”. It is a kind of idle CPU time. If the CPUs get busier, iowait can fall while the disk is just as slow. Treat it as a hint to look at storage, never as a measure of how bad storage is.

The kernel’s pressure files are the better saturation signal. /proc/pressure/io reports the share of time tasks were stalled on I/O, as in the load average lesson.

Who is doing it?

pidstat -d 1            # per-process kB read/written per second
sudo iotop -o           # interactive, only processes doing I/O
ps -eo state,pid,cmd | awk '$1 == "D"'

iotop relies on the kernel’s per-task delay accounting, which newer kernels leave off by default for performance, so it may ask you to enable it. pidstat -d does not need it. Processes in D state are the ones blocked waiting, which is what pushes the load average up with idle CPUs. /proc/<pid>/io from processes through /proc holds the raw per-process counters.

I/O schedulers

The block layer can reorder and merge requests before they reach the device. The kernel’s scheduler documentation shows how to inspect and change it:

cat /sys/block/nvme0n1/queue/scheduler
# the active one is in brackets, e.g. [none] mq-deadline kyber bfq
echo mq-deadline | sudo tee /sys/block/sda/queue/scheduler

The options are none, which passes requests straight through, mq-deadline, which bounds latency and suits SATA disks, bfq, which gives fairness between processes and suits desktops and slow disks, and kyber. Fast NVMe devices have deep hardware queues of their own and usually run none. Change the scheduler only with a measured reason. A udev rule from udev and device files makes the choice persistent.

None of the Linux commands were run. There is no Linux machine here. Field definitions come from the iostat and mpstat man pages and the kernel’s scheduler and PSI documents, read 2026-11-28.

About the video

The embed is all of BashLab’s “Linux Performance Troubleshooting — Episode 1: The I/O Wait Nightmare”, November 2025, about 18 minutes. Its chapters simulate disk pressure with dd, watch %wa rise in top, read iostat, find D-state processes with ps, explain why load rises while CPU is idle, find the culprit with pidstat, and finish with strace. That covers this lesson’s workflow closely. It does not, going by its chapters, cover the %util caveat or schedulers. Red Hat’s scheduler video is in deeper. BashLab is a small channel, so I judged the video from its chapters and description, and English from its English caption track.

Where this fits

pidstat names the process. To see exactly what that process is asking the kernel to do, trace its system calls: tracing system calls with strace.

Check yourself

  1. 01An NVMe drive shows `%util` at 100% but `r_await` at 0.2 ms and modest IOPS. Is the disk the bottleneck?

    Probably not. `%util` only says a request was in flight all the time, and NVMe serves many requests in parallel. Low await means requests are fast, so look elsewhere or test the device's real limits.

  2. 02A cloud disk shows `w_await` jumping from 2 ms to 80 ms with `aqu-sz` climbing, at a steady write rate. What might be happening?

    The volume is saturated, possibly throttled at its provisioned IOPS or throughput limit. Requests queue, so each one waits longer. Check the provider's volume metrics and the workload's write pattern.

  3. 03Why can `%iowait` go down while an application's disk latency goes up?

    iowait counts idle CPU time while I/O is outstanding. If the CPUs become busy with other work, there is less idle time to label as iowait, even though the disk is just as slow.

  4. 04How do you find which process is responsible for heavy disk writes?

    `pidstat -d 1` lists per-process read and write rates. `iotop` does the same interactively if delay accounting is available. Processes in D state show who is waiting.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark