iostat and vmstat — Busy, Waiting, Swapping, or None of the Above

ByLinuxtastic

November 29, 2026

“The server is slow” is a sentence with four different diagnoses hiding in it: the CPUs are busy, the CPUs are waiting for disks, the memory has run out and the machine is swapping, or none of those and the slowness is somewhere else entirely. vmstat separates those four in one line per second, and iostat takes the disk case from “waiting” to “which device, how badly, and whether it is the device or the queue in front of it”. Between them they are the first ten seconds of every performance investigation, and the reason both tools print a line a second is that the first thing you need is not a number but a shape.

vmstat 1            # one line a second until Ctrl-C; -w for wide columns, -S M for megabytes
iostat -xzy 1       # extended stats, skip idle devices, skip the since-boot report

vmstat is in procps and is on every machine. iostat is in sysstat (apt install sysstat, dnf install sysstat), which also brings sar, pidstat and mpstat; on Debian and Ubuntu the package’s history collector is off until you set ENABLED="true" in /etc/default/sysstat, which is worth doing on any server you will one day be asked about retrospectively.

Reading vmstat

$ vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- -------cpu-------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st gu
 0  0      0 7699520   1068 191148    0    0   306    77  624    5  1  1 99  0  0  0
 0  0      0 7699464   1068 191268    0    0     0     4  134  140  1  0 100  0  0  0
 4  0      0 7699212   1072 191416    0    0     0     0  520  580 100  1  0  0  0  0
 0  4      0 7710368   1272 192180    0    0 1056768  0 3351 5876  0 10 37 46  7  0

The first line is the average since boot, and it is almost never what you want. Read from the second line down, or pass -y to drop it. The third and fourth lines above were taken with four busy-loop processes running and then with four processes reading a disk flat out, and they are the two shapes to learn.

ColumnMeaningWhat to think when it is high
rProcesses runnable: running or waiting for a CPUMore than the CPU count, sustained: CPU-bound. The 4 above on a two-CPU machine, with us at 100
bProcesses blocked in uninterruptible sleep, nearly always disk I/ODisk-bound. The 4 above, with wa at 46 and bi at a gigabyte a second
swpdSwap in use, kBOn its own, nothing: old pages that were swapped out once and never needed since. Watch si/so instead
free buff cacheUnused memory; block-device metadata; the page cacheLow free with high cache is a healthy machine. Low free with low cache is one that is about to swap
si / soSwapped in / out, kB per secondAny sustained non-zero so is memory pressure now, not in the past. The machine is thrashing when both are high together
bi / boBlocks read from / written to block devices, kB per secondThe disk traffic itself; go to iostat for which device
in / csInterrupts and context switches per secondTens of thousands of cs with little work done: lock contention or far too many threads
us / syCPU time in user code / in the kernelHigh sy with low us: the application is making the kernel do the work — small I/Os, many syscalls, strace -c next
idIdle—
waIdle while at least one process waits for I/ODisk-bound, with a caveat in the box below
stSteal: time the hypervisor gave your CPU to another guestOn a VM, sustained st is a noisy neighbour or an oversold host, and nothing on this machine will fix it. The 7 above was measured on a cloud VM
guGuest: time this host spent running its own virtual machinesOnly on a hypervisor

Two of the most-quoted numbers in these tools measure “busy”, not “saturated”, and the difference is the whole diagnosis. wa in vmstat is a share of idle time: it counts seconds in which a CPU had nothing to do and some process was waiting on a disk. Give that machine a CPU-bound job as well and wa drops to zero while the disk wait is exactly as bad as before, because the CPU is no longer idle. A low wa rules out nothing; look at b, which counts the waiting processes directly. %util in iostat has the same shape: it is the fraction of time the device had at least one request outstanding, which was a saturation measure when a disk could do one thing at a time and is not one now. Measured for this page on a virtual disk: one sequential reader produced 1,141 reads a second at 1.16 GB/s with %util at 83 and aqu-sz 0.89; four readers at once produced 2,126 reads a second at 1.5 GB/s, %util 100, aqu-sz 6.72 and r_await four times higher. The device was at 83% “utilisation” with another 30% of throughput still available, and at 100% it was still serving more. The saturation signal is await rising together with aqu-sz: requests are queuing and each one is taking longer. %util at 100 with aqu-sz near 1 and a flat await is a device being used, not a device in trouble.

Reading iostat -x

$ iostat -xzy 1
Device     r/s     rkB/s  rrqm/s  %rrqm r_await rareq-sz   w/s   wkB/s  wrqm/s  %wrqm w_await wareq-sz  d/s  dkB/s  f/s f_await  aqu-sz  %util
vda    1141.00 1164508.00    0.00   0.00    0.78  1020.60  0.00    0.00    0.00   0.00    0.00     0.00 0.00   0.00 0.00    0.00    0.89  83.20
vda    2126.00 1515520.00    0.00   0.00    3.16   712.85  0.00    0.00    0.00   0.00    0.00     0.00 0.00   0.00 0.00    0.00    6.72 100.00
vda    1720.00    6880.00    0.00   0.00    0.16     4.00  1.00    4.00    0.00   0.00    1.00     4.00 0.00   0.00 0.00    0.00    0.27  28.80

Three one-second samples from the same disk: one big sequential reader, four of them, and sixteen processes each doing 4 KB random reads. The third line is the one that catches people out — 1,720 operations a second is a busy-sounding number, and it is moving under 7 MB/s, because each request is 4 KB. rareq-sz (average request size) is how you tell a disk doing a lot of small work from one doing a little big work, and the two have completely different fixes.

ColumnMeaningRule of thumb
r/s w/sReads and writes completed per second, after mergingThe IOPS the device actually did
rkB/s wkB/sThroughputCompare with what the device is rated for, not with what feels like a lot
rrqm/s %rrqmRequests merged by the scheduler before reaching the deviceHigh merging is good; it means sequential access the kernel could batch
r_await w_awaitMilliseconds per request, queue time includedUnder 1 ms SSD/NVMe healthy; 5–20 ms spinning disk healthy; climbing while load is flat means queuing
rareq-sz wareq-szAverage request size, kB4 means random I/O; hundreds means sequential
aqu-szAverage number of requests in the queueSustained above the device’s parallelism (1 for a disk, tens for NVMe) means requests are waiting
d/s dkB/sDiscards (TRIM) per secondA burst after fstrim is normal; continuous discards from a database can hurt
f/s f_awaitFlushes (cache sync) per second and their latencyA database with high f_await is paying for every commit here
%utilTime with at least one request outstandingBusy, not saturated. See the box

If you have an older reference that mentions svctm, the per-request service time: it was never measured, only estimated, and current sysstat has removed it. await and aqu-sz together are what it was trying to tell you.

The flags that matter

FlagToolDoes
1 / 1 10bothInterval in seconds, optional count. Without an interval, one since-boot report
-ybothSkip the since-boot first report
-w / -S MvmstatWide columns that stop running into each other / memory in megabytes
-tbothTimestamp each line, for pasting into an incident report
-avmstatActive and inactive memory instead of buff and cache
-d / -DvmstatPer-disk counters since boot / their sum. iostat is better for this
-svmstatEvery counter it knows, once, as a list: forks, pages paged, boot time
-xiostatExtended device statistics. The useful form; the default is throughput only
-ziostatOmit devices with no activity in the interval
-d / -ciostatDevices only / CPU only
-p sdaiostatInclude that device’s partitions
-NiostatDevice-mapper names (vg-lv) instead of dm-3
-hiostatHuman-readable units and a layout that fits a terminal
-o JSONiostatJSON, for a script or a dashboard

The four shapes

CPU-bound: r above the CPU count, us or sy near 100, b and wa at zero. The next tool is top or pidstat 1 to name the process, and if sy dominates, strace -c on it. Disk-bound: b above zero, bi or bo high, and in iostat one device with await and aqu-sz both climbing; iotop or pidstat -d 1 names the process. Memory-bound: so sustained above zero, free and cache both small, and often b and bi rising too because swap is disk — Memory, Swap and the OOM Killer covers what happens next. None of the above: everything near idle while users complain. Then the machine is waiting on something it does not count here: a network round trip, a lock, a remote database, a DNS timeout. ss and strace -T on the slow process are where that investigation goes.

One number is not a shape. Run both tools for at least ten seconds, long enough to see whether a spike is a spike or the baseline, and when the problem is intermittent leave sar collecting so that tomorrow’s question about last night has an answer: sar -u, sar -d and sar -r are these same columns, recorded every ten minutes.

Common problems

SymptomCauseFix
The numbers look fine but the machine is notYou read the first line, the since-boot averageRead from line two, or use -y
wa is low, disks are obviously slowwa only counts idle time; a busy CPU hides itRead b, and await in iostat
%util is 100 and someone wants a bigger disk%util measures busy, not saturatedDecide on await and aqu-sz; see the box
swpd is large; panicPages swapped out long ago and not needed sinceLook at si/so now. Zero means no pressure now
free is tinyThe page cache is using it, as designedRead cache next to it; free -h shows “available”
iostat shows dm-2 and you do not know which volume that isDevice-mapper names are not resolved by default-N, or lsblk to map them
High r/s but tiny throughputSmall random I/O; rareq-sz is 4Different problem from bandwidth: more spindles or an SSD, or fix the access pattern
st is consistently above a few percentHypervisor is taking your CPU timeNothing in the guest fixes it; move the VM or talk to the provider
sar says “Cannot open /var/log/sysstat/sa29”The collector is disabledENABLED="true" in /etc/default/sysstat then systemctl restart sysstat

Quick reference

vmstat -wy 1                 # the shape: r and b, si/so, us/sy/wa/st
vmstat -wy -S M 1 10         # ten seconds, megabytes, no boot-average line
iostat -xzy 1                # every active device, extended, live
iostat -xzy -N 1 vg0-data    # one LVM volume by name
iostat -xzy -p nvme0n1 1     # a device and its partitions
iostat -c 1                  # CPU breakdown only, including steal
pidstat -d 1                 # which process is doing the disk I/O
sar -d -s 02:00 -e 03:00     # yesterday's disk numbers at 2 a.m., if sysstat is collecting

Related reading