Monitoring
High Load Average but Low CPU on Linux: Find the Cause
Load average counts tasks waiting on disk as well as tasks using the CPU. How to read vmstat, list the stuck tasks and check I/O pressure to find the cause.
By Techie Gain4 min read
Load average is not CPU use. On Linux it counts the tasks that are running or waiting for a CPU, and also the tasks stuck in uninterruptible sleep, which is almost always a wait for a disk or a network filesystem. A server can sit at a load of 15 with its CPUs idle, and the number is telling you the truth: something is waiting. This is how to find what.
We reproduced it on a six-CPU test machine, in a Debian 12 container. Sixteen writers shared a disk limit of 4 MiB a second, set with a cgroup, so each one spent nearly all its time waiting for the disk. After 150 seconds the one-minute load average was 14.78. The slower averages still held an earlier test on the same machine.
Read three numbers first
Compare the load with the number of CPUs from nproc, then run vmstat 1. Its first row is an average since boot, so read the rows after it. Here are two of them, trimmed to the columns that matter:
procs ---io--- ------cpu-----
r b bo us sy id wa st
1 16 4096 0 0 0 100 0r is the tasks running or waiting for a CPU. b is the tasks blocked in uninterruptible sleep. wa is the time the CPUs sat idle with disk requests outstanding. One runnable task, sixteen blocked and no user or system time at all: the machine is not computing, it is waiting. A busy CPU looks the opposite way. Twelve busy loops on four of the six CPUs gave r 12, b 0, wa 0 and us near 70 percent, with CPU pressure at 96 and I/O pressure at 0.
List the tasks that are waiting
Tasks in the D state are the ones counted in b, and wchan names the kernel function each is sleeping in:
bash
ps -eo state,pid,wchan:26,comm | awk '$1=="D"'D 1291 blk_io_schedule ddWe got sixteen lines like that one, all in blk_io_schedule, the block layer waiting for I/O. When the same writers synced every write instead, the list showed jbd2_log_wait_commit, the ext4 journal waiting to commit. The names depend on the kernel, so use them as a pointer, not a diagnosis. Sixteen copies of one program means that program is the source. A mix of unrelated programs means they share something that is slow: a disk, a mount, a limit.
Ask the kernel how much time was lost
Pressure stall information says what share of recent time tasks were stalled, and on which resource:
bash
cat /proc/pressure/iosome avg10=99.01 avg60=91.09 avg300=46.06 total=278421875
full avg10=97.95 avg60=90.05 avg300=43.70 total=240466316some is the share of time at least one task was stalled, and full the share when every task that could otherwise run was stalled, averaged over 10, 60 and 300 seconds. At the same moment the CPU line showed some avg10=0.16 and memory showed 0.00, so the stall was I/O and nothing else. ls /proc/pressure tells you whether your kernel has it.
The disk may look innocent
The usual next step is iostat -x 1, from the sysstat package. In our test it reported the disk as idle, with a write wait of 0.75 ms and 0.00 percent utilisation. The delay was the cgroup's limit, which holds a task back before its request reaches the disk. A container or service with a write limit behaves this way. When iostat is quiet and tasks are still stuck, look at limits and at what the tasks are waiting on, not at the disk.
When the disk really is the problem, iostat shows high utilisation and write wait, and pidstat -d 1 lists which processes are writing.
Other causes with the same symptom
We reproduced the first of these. The others come from the documentation and from what we have seen on servers, so check each before trusting it.
- A slow or busy disk. A backup, a log flood or a database checkpoint. Compare
iostatwith the timing of the load. - A network filesystem that stopped answering. Tasks wait on the mount, and even
dforlscan hang. Checkmount | grep -E 'nfs|cifs'. - Swapping. Non-zero
siandsoinvmstatand pressure in/proc/pressure/memory. - A failing disk. I/O errors in
dmesg.
What not to do
kill -9 does not remove a task that is waiting inside the kernel. The signal arrives when the call returns, which is the moment the wait ends anyway. Restarting a service often only moves the same writers somewhere else.
Do not judge a fix by the load figure straight away. It is a moving average. When we stopped the writers the one-minute load fell from 15.16 to 5.57 after a minute, so give it a couple of minutes.
Alerting on load
A load of 15 means little until you divide by the CPUs: 2.5 per CPU on that machine. Waiting counts as load, so a high load per CPU with idle CPUs catches I/O stalls that an alert on CPU use never sees.
In Techie Gain, the Server health monitor reads the one-minute load average collected over SSH every five minutes, divides it by the core count and alerts above 4 per core unless you change it. On a six-core server that is a load of 24, so the test above would not have alerted at the default. A load alert is reported and never auto-fixed, because Auto-Fix has no safe action for a server that is waiting. How to create a monitor covers the thresholds.
Keep reading
Monitoring
What to Monitor on a Linux Server
A short, opinionated list of what to watch on a Linux server, the thresholds worth alerting on, and what to leave out so alerts stay worth reading.
4 min read
Monitoring
Linux OOM Killer: Find Out What It Killed
A service keeps dying and its own log says nothing. How to confirm the kernel's OOM killer did it, read its log line and stop it coming back on a small server.
5 min read
Operations
Linux Disk Full: Find What Is Using the Space
df says full, df says free, or the numbers disagree. A calm order of checks for a full Linux disk: inodes, deleted files, journald, Docker and logs.
4 min read