“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 reportvmstat 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 0The 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.
| Column | Meaning | What to think when it is high |
|---|---|---|
r | Processes runnable: running or waiting for a CPU | More than the CPU count, sustained: CPU-bound. The 4 above on a two-CPU machine, with us at 100 |
b | Processes blocked in uninterruptible sleep, nearly always disk I/O | Disk-bound. The 4 above, with wa at 46 and bi at a gigabyte a second |
swpd | Swap in use, kB | On its own, nothing: old pages that were swapped out once and never needed since. Watch si/so instead |
free buff cache | Unused memory; block-device metadata; the page cache | Low free with high cache is a healthy machine. Low free with low cache is one that is about to swap |
si / so | Swapped in / out, kB per second | Any sustained non-zero so is memory pressure now, not in the past. The machine is thrashing when both are high together |
bi / bo | Blocks read from / written to block devices, kB per second | The disk traffic itself; go to iostat for which device |
in / cs | Interrupts and context switches per second | Tens of thousands of cs with little work done: lock contention or far too many threads |
us / sy | CPU time in user code / in the kernel | High sy with low us: the application is making the kernel do the work — small I/Os, many syscalls, strace -c next |
id | Idle | — |
wa | Idle while at least one process waits for I/O | Disk-bound, with a caveat in the box below |
st | Steal: time the hypervisor gave your CPU to another guest | On 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 |
gu | Guest: time this host spent running its own virtual machines | Only 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.80Three 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.
| Column | Meaning | Rule of thumb |
|---|---|---|
r/s w/s | Reads and writes completed per second, after merging | The IOPS the device actually did |
rkB/s wkB/s | Throughput | Compare with what the device is rated for, not with what feels like a lot |
rrqm/s %rrqm | Requests merged by the scheduler before reaching the device | High merging is good; it means sequential access the kernel could batch |
r_await w_await | Milliseconds per request, queue time included | Under 1 ms SSD/NVMe healthy; 5–20 ms spinning disk healthy; climbing while load is flat means queuing |
rareq-sz wareq-sz | Average request size, kB | 4 means random I/O; hundreds means sequential |
aqu-sz | Average number of requests in the queue | Sustained above the device’s parallelism (1 for a disk, tens for NVMe) means requests are waiting |
d/s dkB/s | Discards (TRIM) per second | A burst after fstrim is normal; continuous discards from a database can hurt |
f/s f_await | Flushes (cache sync) per second and their latency | A database with high f_await is paying for every commit here |
%util | Time with at least one request outstanding | Busy, 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
| Flag | Tool | Does |
|---|---|---|
1 / 1 10 | both | Interval in seconds, optional count. Without an interval, one since-boot report |
-y | both | Skip the since-boot first report |
-w / -S M | vmstat | Wide columns that stop running into each other / memory in megabytes |
-t | both | Timestamp each line, for pasting into an incident report |
-a | vmstat | Active and inactive memory instead of buff and cache |
-d / -D | vmstat | Per-disk counters since boot / their sum. iostat is better for this |
-s | vmstat | Every counter it knows, once, as a list: forks, pages paged, boot time |
-x | iostat | Extended device statistics. The useful form; the default is throughput only |
-z | iostat | Omit devices with no activity in the interval |
-d / -c | iostat | Devices only / CPU only |
-p sda | iostat | Include that device’s partitions |
-N | iostat | Device-mapper names (vg-lv) instead of dm-3 |
-h | iostat | Human-readable units and a layout that fits a terminal |
-o JSON | iostat | JSON, 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
| Symptom | Cause | Fix |
|---|---|---|
| The numbers look fine but the machine is not | You read the first line, the since-boot average | Read from line two, or use -y |
wa is low, disks are obviously slow | wa only counts idle time; a busy CPU hides it | Read b, and await in iostat |
%util is 100 and someone wants a bigger disk | %util measures busy, not saturated | Decide on await and aqu-sz; see the box |
swpd is large; panic | Pages swapped out long ago and not needed since | Look at si/so now. Zero means no pressure now |
free is tiny | The page cache is using it, as designed | Read cache next to it; free -h shows “available” |
iostat shows dm-2 and you do not know which volume that is | Device-mapper names are not resolved by default | -N, or lsblk to map them |
High r/s but tiny throughput | Small random I/O; rareq-sz is 4 | Different problem from bandwidth: more spindles or an SSD, or fix the access pattern |
st is consistently above a few percent | Hypervisor is taking your CPU time | Nothing in the guest fixes it; move the VM or talk to the provider |
sar says “Cannot open /var/log/sysstat/sa29” | The collector is disabled | ENABLED="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 collectingRelated reading
- The Life of a Write — where
bo,w_awaitandf_awaitare measured on the way from the page cache to the medium - The Life of a Block Device — the queue that
aqu-szcounts and the scheduler that does the merging - Memory, Swap and the OOM Killer — what
si/soare the early warning of - Processes and Memory — what
free,buffandcacheare, and why lowfreeis normal - Processes — naming the process once
vmstathas named the shape - Disk Space — the other disk question, capacity, which these tools do not answer

