I know you are all familiar with load checking commands, we have many options to display the load average on the screen. I thought of explaining how the system calculates this load or load average. The logic is very simple and this is really good to know.[google-translator]
We get load average in numbers and these numbers will give us information about how engaged our CPU, disks, Memory and other resources are. This might appear a little tough at first but believe me you can be a master once you try to familiar with them.
On a Unix platform, including Linux, computational work does by the system is always taken into account. So the system load is nothing but the computational work performed by the system. This value is displayed as number and we call it as load.
If a system is in its idle state, the load average becomes zero. All the processes which are running on the system will add 1 to the load average no matter whether they are waiting for the CPU or using the CPU. In Unix systems they just count the processes which are waiting for the CPU, but on Linux they count the other resources as well, for your information – they count the processes waiting to read from or write to disk.
The load value is not constant, as the processes request the CPU in a very random manner, load also changes in every seconds or in every splits of seconds. We cant actually say that load is this much or that much, it varies with time.
Even if you could check the load at any given specific time, that number would be basically meaningless and will not help you in anyway. That’s why Unix-like systems don’t display the current load. it displays the load average — an average of the system’s load over several periods of time. This helps us to see how much work the system has been performing.
How to find the load average?
The load average can be checked in many ways. There are commands which display this and also graphical utilities are also available, for example system monitoring tools available with GNOME systems. The below are the commands that are normally used to check the load average on a system.
You can use any of the three to get the load average, the output of the top command is given below:
Interpreting the Load Average Output
<strong>load average: 0.78, 1.90, 4.25</strong>
In the above example, the load average for a system is given, you may not get any idea when you see this for the first time.
IMPORTANT: From left to right the output gives the load average on the server for the last 1 minute, 5 minutes and 15 minutes. That is for more clarity, the load average is something as given below:
load average over the last 1 minute: 0.78 load average over the last 5 minutes: 1.90 load average over the last 15 minutes: 4.25
What information these numbers have?
The load average calculation varies when you have more CPU’s for your system, let’s assume that you have a single CPU, I am taking the above example itself to explain these numbers.
over the last 1 minute: The CPU was idled for 22% of the time (0.78). over the last 5 minutes: The CPU overloaded by 90%, On average .90 processes were waiting for the CPU. (1.90) over the last 15 minutes: The computer was overloaded by 325% on average. On average, 3.25 processes were waiting for the CPU. (4.25)
You can simply calculate these with the below formula:
CPU overload = Average load – 1
Example: Assume that the load is 4 on the system, then CPU overload = 4-1 which gives you 3, so 300% overload.
If you are getting a negative value for this, then the CPU has idle time (ex: .70-1= -0.30, which means 30% idle).
Load average on systems with multiple CPU’s:
In a system with multiple CPU’s, these math will not do the trick. For example if we have load average 2 on a single CPU system, the CPU overload is 2-1 = 100%. Assume that you have 2 CPU’s, then the load handled by the CPU is its complete usage, you have to calculate it as 2-2 = 0%. two different processes were using two different CPUs the entire time. On a system with four CPUs, this would be half usage — two processes were using two CPUs, while two CPUs were sitting idle.
So in general, we can say we need to know the number of CPU’s possessed by the system. Load average is very useful in the server environment, it helps in performance evaluation. If the load goes high, we may have to think about adding more resources to the system or optimize/terminate applications or processes that wasting the resources.
That’s all guys, thank you so much for reading!
Share this with friends, love to get comments from you! See you! 🙂