12

I understand that the load balance is a way of measuring how busy the CPU is. However, I don't understand how a load average of 0.00 can exist. Doesn't the kernel always run? Doesn't that take part of the CPU load?

3
  • 6
    Note that in the majority of cases what you see as 0.00 is really 0.0001 or so
    – PlasmaHH
    Nov 23 '17 at 10:40
  • 1
    In the old days it was the average length of the run queue. In other words, how many processes was ready to execute (and not waiting for I/O etc.). If there isn't any it is 0.00. These days this is in my experience only possible if you do not run a graphical desktop but just a GUI-less server. Nov 23 '17 at 12:14
  • Just for completeness, I think it was one of the BSDs that for a while had a kernel bug where the kernel idle thread was counted into the load average, causing a load average of 1.00 when the system was doing nothing at all. That got fixed pretty quickly.
    – user
    Nov 24 '17 at 12:16
17

The load average over a period of time is the average number of processes which were competing for CPU over that period of time. The "kernel" doesn't run if there is nothing to be done; more specifically, if there is nothing to be done the CPU is given to a special "idle" thread which is not counted (and which may do things like put the CPU is a state where it waits for an interrupt).

So, for example, a load average of 0.6 over 5 minutes usually means that during those 5 minutes the CPU was used for a total 3 minutes by some process(es) (or by the kernel), and for a total of 2 minutes it was idle. But, as @UKMonkey observes, it might mean that after 4 and a half minutes of doing nothing, 6 processes competed for the CPU for the last 30 seconds...

The CPU is idle is there is no process which wants to use it to run code, because all processes are either waiting for an input or output operation to complete or are sleeping waiting to be woken up at a certain future time.

@Panther's links provide more in-depth discussions of load averages.

2
  • 1
    The load average of 0.6 for 5 minutes could also mean it did nothing for 4 and a half minutes - and then in the last 30 seconds there were a significant number of processes awaiting CPU time... It's not an indication of how much work the CPU has done - but how many processes have been waiting to use it.
    – UKMonkey
    Nov 23 '17 at 17:20
  • @UKMonkey: Perfectly true... Averages are averages and the same average can be obtained in many ways. Edited the answer to explain that a moderate average does not mean that peaks are also reasonable.
    – AlexP
    Nov 23 '17 at 17:24
13

A load average is a measure of how overloaded a CPU core is in terms of number of processes wanting to use it at once.

The following assume a single core (single thread) CPU:

  • 0.0

    The CPU is not doing anything at all. If a process were to start using the CPU then it would be the only one using it.

    An idle CPU does not mean there are no processes running. For example, background services and the kernel are still running, and are still occupying memory. They just aren't using any CPU, because they aren't doing anything.

  • 1.0

    The CPU is at maximum usage, but there is zero contention between processes for use of the CPU. That is, only a single process is running so it's able to claim 100% of the CPU time for itself. Alternatively, multiple processes are running but none are claiming 100% CPU, and their combined CPU usage adds up to 100%. They are all still running as fast as they would run even if they had the CPU to themselves.

  • Greater than 1.0

    The CPU is at maximum usage, and there are multiple processes wanting to use it concurrently so they are effectively running more slowly than they would otherwise be able to run on an idle CPU. For example, a load average of 3.0 indicates processes are running at one third the speed they want to run. A load average of 50.0 indicates processes are running at 1/50 the speed they want to run, due to all the other processes running. That is, figures higher than 1.0 indicate that the available CPU is being stretched between more and more processes.

Having a multiple core CPU does not change what the figures mean but can change their interpretation. For example, if you have a 4 core CPU, then a load of 1.0 is still equivalent to one process using 100% CPU on one core, but there are three other cores. So on a 4 core CPU, the point of maximum efficiency is 4.0, not 1.0 - and the point at which everything is running at 1/3 efficiency is 12.0, not 3.0. To add to the complexity, a single process may have more than one thread each claiming CPU of its own. So a single process can use 100% of all 4 cores if it's multi-threaded.

Important note

CPU usage is only one resource which may be limit a process' performance. I/O is another, and is not factored into CPU load. A process using a certain amount of CPU will not necessarily be able to use more on a lighter-loaded machine as they may hit other bottlenecks.

What is the best load average

It really depends on what you are doing and whether you prefer responsiveness, or for the CPU to work as hard as possible.

For something that needs to get as much done as possible, the load average should be at or slightly above the number of cores. Anything much greater than this indicates that you could get more done, more quickly, if you separated tasks across more computers/servers.

For something that needs to be as responsive as possible (react quickly), the load average should be a comfortable margin less than the number of cores, such as half or one third, which allows some intermittent variation before any slowdowns occur.

For a virtualisation guest (eg KVM) the lower the load average the better, because you are actually sharing CPU with other guests on the same host.

2
  • I was startled to see that sometimes threads "waiting on I/O" are included in load average serverfault.com/a/524818/27813 it seems...
    – rogerdpack
    Nov 24 '17 at 3:56
  • @rodgerpack Yes, D state processes are always included in the load average in Linux. Yes, it's confusing. Yes, we should primarily look at other metrics than load avg.
    – kubanczyk
    Nov 24 '17 at 8:23
2

A load average of 0.00 basically means your system is idle and that there is no delay or stress or bottleneck to your CPU over the time measured.

It does not mean your CPU is inactive, it just means that if a process wants CPU time, there is no wait.

It is hard to say more from what little you posted as it can depend on how you measured your load (system, per user ?) and over what time .

For some details and interesting reading see

https://www.tecmint.com/understand-linux-load-averages-and-monitor-performance/

http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages

http://www.brendangregg.com/blog/2017-08-08/linux-load-averages.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.