Linux : Understanding load average and % CPU

cpucpu usagecpu-architecturelinuxperformance

When I execute top command on my ubuntu system I see below results

top – 07:58:58 up 1:21, 1 user, load average: 0.82, 0.73, 0.55
Tasks: 293 total, 1 running, 292 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.8 us, 0.8 sy, ….

I need to understand load average and %cpu.

My understanding based on my knowledge and high-cpu-utilization-but-low-load-average

Load Average

Load average is a measurement of how many tasks are waiting in a kernel run queue (not just CPU time but also disk activity) over a period of time.
Does it mean .83 tasks are waiting per above results ? How it can be decimal number ? Also what is three different figures 0.83 0.73, 0.55 ?

%CPU

This represent the for how much time in last x seconds, CPU was working. For example :- if CPU utilization displays 60%, it means in last x seconds cpu was working 60% of time in x seconds.Is my understanding correct ? If yes what %Cpu(s): 0.8 us represents ?

Also if I have 4 CPU processor, and %CPU displays 50% does it mean either all cores are working 50% or 2 CPU are working 100% ?

Best Answer

Understanding Load Average: 0.83 0.73, 0.55

  • Load is the measure of the amount of computational work a system performs. The three values is the load average over a time interval. The intervals are, the last 1 minute, 5 minutes, and 15 minutes. Load average is computed as an exponential moving average. If you wish, you can take a deep dive and read Examining Load Average

  • Single Core System

    • The load average value varies in range. With a single core system the value 0.83 means your CPU was at 83% capacity within the last minute. A value of 1.0 would mean your CPU is at exact capacity (100%). With the value 1.0 the system will be overloaded by adding even a little bit of additional work. A value greater than 1.0 means it's getting more than it can handle. This isn't bad, it just means that more processes are waiting for CPU time. You would see the slowness of the computer.
  • Multi-Core System

    • With a multi-core system, you divide the load average by the number of cores you have. So for example, having a load average of 0.83 and having 4 cores, you would take 0.83 / 4 to get 0.2075 or (0.83 / 4) * 100 to get 20.75% capacity. With a quad-core system, if you had a load average greater than 4.0 that would indicate all cores are at 100% capacity, and any overload will result in processes waiting for CPU time.
  • Overloading occurs when you go over your max capacity. The load average as an overload can be a bit confusing to read because it's based on your cores. If you have a quad-core CPU, you won't overload until the load value is over 4.0. If the first load average value was 5.50 that would mean your system is 150% overloaded, and on average 1.5 processes in the last minute had to wait for CPU time.

Understanding %Cpu(s): 0.8us, 0.8sy....

  • This section is a displays HOW the CPU has been used. Each suffix stands for something specific, and indicates how much time the CPU spent on that set of tasks. If you add up all of the numbers in that output row, it will add up to 100%.

  • The tasks are defined as... source

    • us is the percentage of the CPU for user processes
    • sy is the percentage of the CPU for system processes
    • ni is the percentage of the CPU processes with priority upgrade nice Ni easter egg
    • id is the percentage of the CPU not used
    • wa is the percentage of the CPU processes waiting for I/O operations
    • hi is the percentage of the CPU serving hardware interrupts
    • si is the percentage of the CPU serving software interrupts
    • st in a virtualized environment, a part of the CPU resources are given to each virtual machine (VM). The OS detects when it has work to do, but it cannot perform them because the CPU is busy on some other VM. The amount of time lost in this way is the steal time
Related Question