5

In this page, it says that the first three columns of the output of /proc/loadavg measure CPU and IO utilization of the last one, five, and 10 minute periods.

Does a single value reveal both CPU and IO utilization? What if I just want to know the CPU utilization? or just the IO utilization?

Or, from that single value, how can I tell how heavy the server is?

shintaroid
  • 269
  • 4
  • 9

3 Answers3

5

Load average mean how many processes are waiting in queue. It's not only CPU metric and it does not show the CPU utilization in %. Load average show approximate system load.

See UNIX Load Average for better understanding.

In this document:

  1. The “load” is not the utilization but the total queue length.
  2. They are point samples of three different time series.
  3. They are exponentially-damped moving averages.
  4. They are in the wrong order to represent trend information.

To calculate CPU idle on current time use /proc/stat (taken from here):

average idle percentage X % = ( idle * 100 ) / ( user + nice + system + idle + iowait + irq + softirq )

So to calculate CPU utilization use:

grep 'cpu ' /proc/stat | awk '{usage=100-($5*100)/($2+$3+$4+$5+$6+$7+$8)} END {print usage}'

CPU utilization calculation is not such an easy task as it seems. See similar topic

Some conclusions:

  1. Do not analyze only CPU utilization without other hardware/software metrics. Use disk, RAM, network usage for a full conclusion (and may be per proccess load);
  2. Do not make conclusion based only on Load Average params. You can use Load Average as start point for troubleshooting performance issues;
  3. Use approach:

if 1min load more than 5/10min load -> system load is growing

if 1min load less than 5/10min load -> system load is decreases

And read great article: Linux Load Averages: Solving the Mystery

4

Does a single value reveal both CPU and IO utilization?

Yes, it is a rough indication of combined CPU and disk utilization, but not a percentage. Zero means there is no load. If you have a system with four CPU cores, a value of four would mean to system is fully loaded, a value of eight would mean the system is overloaded. CPU load is a better metric than computing 100 - idle CPU because the latter doesn't distinguish between the case a system is fully loaded and a system is overloaded.

What if I just want to know the CPU utilization?

have a look to vmstat first column: r. It shows the number of threads using or waiting for a CPU. Same interpretation than with the previous metric.

or just the IO utilization?

Start by looking to ìostat output. Figuring out the disk load from these statistics is more complex than with the CPU as both the disk characteristics (I/O per seconds) and the kind of usage (sequential or random, I/O size) do matter.

Or, from that single value, how can I tell how heavy the server is?

The rule of thumb is if the load average is consistently higher than the number of core/threads available to the OS, the server is overloaded.

jlliagre
  • 61,204
0

the truth is load average is really ugly item.

documentation says it shows smth "average" for 1m 5m 15m.

it s a big lie.

if you launch program that uses 1 cpu thread for 100% for 1 minute - the load average in 1 minute will not be equal 1 . no no no. it will be equal 0.62.

it does not make any real sense.

in 5 minutes the second parameter of load average will not be equal 1. no. the second parameter of LA will be equal 1 only in 18 minutes.

the third parameter of LA will be equal 1 only in 60 minutes.

so the load average doesnt make any real sense.

moreover when it is high it is not clear whether it is high cpu usage of high hdd usage.

useless totally

Alex
  • 540
  • 1
    I wouldn't say it's useless. But you certainly have to keep in mind that it uses exponential damping. How much impact 100% CPU utilization for a duration t has on the load average of an otherwise quiet system (load avg 0) depends on the value of t relative to the averaging time τ: For t ≪ τ the load average would stay close to 0, after t = τ the load average would be at 0.63 and would keep rising approaching 1 for t ≫ τ. See the Wikipedia article for a more detailed discussion. – Martin Konrad May 22 '20 at 21:04