Load Average Explanation
While working with Linux many of us have noticed the Linux "Load Average" but never really put much thought into how this number is generated. Load averages are generated using many different metrics, disk load, CPU usage, memory usage and much more. The load average number is the total number of processes waiting in the run queue.
Using "top" provides insight into the system’s general health status.
The top command provides a view of the following main health statistics:
- Uptime (including days, hours and minutes, the user count and current time and load average)
- The total number of processes along with the number of running processes and sleeping processes
- Memory usage including total memory, used and free memory
- Swap memory usage (useful for troubleshooting slow systems)
The top command looks like this:
The topmost process on the top process list is the process using the highest percentage of CPU. The top command is available on most Unix and Linux variants.
As we’ll learn, CPU usage is not directly related to load average. Load average is an overall view of the system.
The load average rule of thumb
One quick rule of thumb I try to use (to make sure systems do not see any latency … e.g. slow processes, slow page loads, slow queries etc…) is to keep the number of waiting processes in the run queue (the load average represents total number of processes that had to wait for resources in the last 1, 5 and 15 minutes) under the total number of processors in the machine.
To check the number of processors (recognized by the Unix/Linux OS) run the following command:
cat /proc/cpuinfo | grep "processor" | wc -l
Keep in mind this command will return the total number of recognized processors. If you have a hyper-threaded P4 you’ll see two processors when really you only have one core. The same rule applies with the load average rule of thumb.
Keeping the load average under the total processor count will make for a happy, healthy and fast-responding system.