System load: how to determine whether the Linux load value is too high

Source: Internet
Author: User

Anyone who has been familiar with and used unix or linux knows how to view the value of Unix/Linux load. Here I also repeat the method of viewing the load:

[root@aaronw ~]# uptime13:33:37 up 7 days, 1:52, 1 user, load average: 4.15, 2.00, 3.14[root@aaronw ~]# w13:35:35 up 1 days, 1:54, 1 user, load average: 0.00, 0.00, 0.00USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATroot pts/1 192.168.2.2 13:33 0.00s 0.02s 0.00s w

The three values after load average indicate the load of the system in 1 minute, 5 minutes, and 15 minutes. The higher the number, the higher the system load. The first intuition is that the system is not working. When the load average is 0, he thinks it is very low. When it is 10, he thinks it is high. He doesn't need to talk about 20! But in addition to these two extreme situations, when is the critical point of these two values? When someone asks me this question, I don't know how to answer it. I have never considered it in my brain. It has been bothering me for a long time. I think we need to understand him!

Start with the kernel source code of linux! The following code is available in linux 2.6.36:

/*** spu_calc_load – update the avenrun load estimates.** No locking against reading these values from userspace, as for* the CPU loadavg code.*/static void spu_calc_load(void){unsigned long active_tasks; /* fixed-point */ active_tasks = count_active_contexts() * FIXED_1;CALC_LOAD(spu_avenrun[0], EXP_1, active_tasks);CALC_LOAD(spu_avenrun[1], EXP_5, active_tasks);CALC_LOAD(spu_avenrun[2], EXP_15, active_tasks);}

CALC_LOAD is defined as follows:

#define LOAD_FREQ (5*HZ+1) /* 5 sec intervals */#define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */#define EXP_5 2014 /* 1/exp(5sec/5min) */#define EXP_15 2037 /* 1/exp(5sec/15min) */#define CALC_LOAD(load,exp,n) \load *= exp; \load += n*(FIXED_1-exp); \load >>= FSHIFT;

Here we can see that the minimum cycle for getting the load value is 5 seconds. According to the definition in the code, we know that

What is load?

Load refers to the number of active_tasks in the computer within a certain period of time, that is, the length of the task execution queue of the computer and the queue of cpu computing.

How much load is normal?

Since load is the queue of cpu computing, it should be related to the number of cpu processing methods and the number of CPUs. Therefore, I personally think that the load critical value should be determined based on the number of CPUs identified by the system. If the system recognizes 8 CPUs, the load is the critical point. If the load is greater than 8, it is over load.

What is the number of CPUs recognized by the system?

In my opinion, the physical number of CPUs and hyperthread technology are involved. I personally think that four physical CPUs and two dual-core CPUs cannot be the same. Of course, this is a physical layer thing! 4 CPUs are identified in the system. Therefore, the system should be used for identification. After all, the system controls his use.

The CPU height is not the same as the load height.

In Unix/Linux, the cpu usage may often be 100%, but the load is not high! Why? Almost all tasks can interact with the CPU, but the usage frequency of each device is different, resulting in the inability to synchronize. For example, when I/O waits for a read/write operation on the hard disk, the cpu is actually switched to another process. This task is in the waiting state. When there are too many such tasks, the queue length is too large, which means the load is too large, however, in this case, the cpu is allocated to perform other tasks or idle tasks. Therefore, the CPU height is not the same as the load height, and the load height cannot be the same as the cpu height.

Original article: Determine whether the Linux load value is too high

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.