Linux Labs

Inside the system: resources, kernel, processes / Stage 1 of 12

Load average and CPU load

Not running Starting usually ~20 s
Leave the lesson

Step 2 of 7 · theory · 5 min

What the load average counts

The load average grows with processes that have something to do right now — even when they do not need the CPU.

uptime prints how long the machine has been running and three load average numbers — averages over the last 1, 5 and 15 minutes. Each number is how many processes on average were in one of two states:

  • R — the process runs on the CPU or waits in the queue for it. You saw this state in the STAT column of ps.
  • D — the process waits for an operation on a disk or a filesystem to finish, and that wait cannot be interrupted.

Compare the load average with the number of CPUs from nproc. On one CPU, a load of 1 means the CPU was busy all the time; 3 means that on average three processes wanted to run or waited for the disk. When processes in R drive the load, the CPU is busy and id in top is near zero. Your CPU is free — so processes in D make up the load average.

The three numbers show the direction. The first larger than the last — the load has grown over the last minutes; smaller — it is falling. Your first number is above 3 and the last below 1: the processes got stuck recently. The average catches up with the current state gradually — in about a minute the first number covers two thirds of the way. That is why it rises and falls smoothly, even when processes appear or vanish all at once.

Check yourself 1 question

On a server with two CPUs, uptime prints load average: 0.40, 1.90, 2.10. What is happening to the load?

  • The first number is closest to right now — 0.40 on two CPUs. The queue was nearly full earlier: 2.10 is the 15-minute average.

  • The first number is the last minute, the last one is 15 minutes. 0.40 for the minute is below 2.10 for 15 minutes: the load has gone down.

The first number is the one-minute average, the last is the 15-minute one. The first is smaller than the last: there was load, and it is going down. Two CPUs are fully busy at a load of 2, so even earlier the queue did not overflow.

Key points

  • The load average is the average number of processes in the R and D states over 1, 5 and 15 minutes.
  • Compare it with nproc: above the number of CPUs, processes lack CPU time or wait for the disk.
  • The first number larger than the last — the load is rising; smaller — it is falling.
Ubuntu 24.04
Loading…