Understanding Load Average in Linux and when to be worried about it?

The one of the most important task of any Linux Admin includes performance monitoring which includes a parameter "Load Average" or "CPU Load".

Load Average is the value which represents the load on your system for a specific period of time. Also it can be considered the ratio of the number of active tasks to the number of available CPUs.

How to check?

You can use either top or uptime command to view the load average. The output would look like as shown below
$ uptime
 00:07:00 up 4 days,  6:14,  1 user,  
load average: 0.11, 0.14, 0.09

$ top
top - 00:07:12 up 4 days,  6:15,  1 user,  load average: 0.09, 0.13, 0.09

What are the three values?

As you can see three values representing the load average column. These show the load on your system over a significant period of time (one or current, five and fifteen minutes averages).

How do you know your system has a high load?

The most important question as in most cases I have seen how do you determine your system has high load.
Does a high value represents high load average and that your system requires atention?
What is the threshold value for load average?
How can we conclude if the load average value is good or bad?

Before I answer these question first let us understand about multi core and multi processor CPU.

A Central Processing Unit in earlier days used to be having only one processor and the core concept was not their in those days. But with the advancement in technology and the urge of higher speed to meet up demands of IT industry multiple processor were integrated in the same CPU making it multi-processor.

However increasing the no. of processor did increased the working speed of many tasks and performance but it also leads to increase in size, complexity and heat issues. So, in order to continue improvement of performance the core concept was introduced.

Instead of having two CPUs and a motherboard capable of hosting them, two CPUS are taken together and combined to form a dual core processor which will utilize an individual socket using less power and size capable of performing the same amount of task as dual processor CPU.

Bottom Line is that Load value depends on the no. of cores in your machine. For example a dual core is relevant to 2 processor or 2 cores and quad core is relevant to 4 processor or four cores as the maximum value for load.

How do I check the no. of cores on my Linux system?

The information which you see under /proc/cpuinfo can be confusing at times. If you run the below command
$ less /proc/cpuinfo | grep processor
processor       : 0
processor       : 1
processor       : 2
processor       : 3
processor       : 4
processor       : 5
processor       : 6
processor       : 7
processor       : 8
processor       : 9
processor       : 10
processor       : 11
processor       : 12
processor       : 13
processor       : 14
processor       : 15

So as per the above command my system has 16 processors in it. However it really has 8 processors with hyper threading enabled. The hyper threading presents 2 logical CPUs to the operating system for each actual core so it effectively doubles the no. of logical CPU in your system

How to find if hyper threading is enabled
Look out for "ht" in the flags section inside cpuinfo with the below command
$ less /proc/cpuinfo | grep flags | uniq | grep -i  "ht"
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss 
ht tm syscall nx rdtscp lm constant_tsc nonstop_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm

Next let us continue on the calculation of no. of core

The fields we need to compare to find the no. of core are "physical id" and "core id". Run the below command
$ less /proc/cpuinfo | grep "physical id" | sort|uniq | wc -l
2

$ less /proc/cpuinfo | grep "core id" | sort|uniq | wc -l
4

So the no. of cores would be 2x4 = 8 cores

Coming back to our primary question

Understanding Load Average

If the number of active tasks utilizing CPU is less as compared to available CPU cores then the load average can be considered normal but if the no. of active tasks starts increasing with respect to available CPU cores then the load average will start rising.

For example in my case I can see
$ uptime
 00:43:58 up 212 days, 14:19,  4 users,  load average: 6.07, 7.08, 8.07

So as per the no. of cores I calculated i.e 8 cores and seeing the value 6.07 I shouldn't be worried much unless it crosses the red line value i.e. 8 for my case.

I hope I made myself clear

Nhận xét

Bài đăng phổ biến