In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the CPU load in linux". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the CPU load in linux".
Look at the Nagios alert message and find that one of the servers, CPU, is overloaded and the machine is a CentOS system. The information is as follows:
2011-2-15 (Tuesday) 17:50
WARNING-load average: 9.73,10.67,10.49
There are also alarm messages issued in the last two hours:
2011-2-15 (Tuesday) 16:50
WARNING-load average: 10.52,10.10,10.06
2011-2-15 (Tuesday) 15:40
WARNING-load average: 8.27,9.23,9.48
What exactly do the three parameters of the alarm message mean?
9.73,10.67,10.49 represent the average CPU load of the previous minute, five minutes and 15 minutes, respectively. The most important indicator is the last number, that is, the average CPU load of the first 15 minutes. The smaller the better. The so-called CPU load refers to the length of the task queue over a period of time. In popular terms, it refers to how many tasks are using or waiting to use CPU over a period of time.
Second, besides Nagios, what other tools can view CPU load?
You can use the top command, the uptime command, and in particular the top command, which is more powerful than just looking at the CPU load.
Third, how to understand the CPU load? Is it CPU utilization?
To distinguish between CPU load and CPU utilization, they are two different concepts, but their information can be displayed in the same top command. CPU utilization shows the percentage of CPU occupied by the program in real time while it is running, while the CPU load shows the average number of tasks that are using and waiting to use CPU over a period of time. Just because the utilization of CPU is high does not mean that the load must be high. An article on the Internet gives an interesting analogy. I use a phone call to explain the difference between the two. I will explain it according to my own understanding.
In a public telephone booth, one person is on the phone and four people are waiting, each of whom is limited to using the phone for one minute. if someone does not finish the call within a minute, they can only hang up the phone and wait in line for the next round. The phone here is the equivalent of CPU, and the number of people who are or are waiting for a call is equivalent to the number of tasks.
In the course of using the telephone booth, some people will definitely leave after making a call, some people will choose to queue again without finishing the call, and there will be new people queuing here. The change in the number of people is equivalent to the increase or decrease in the number of tasks. In order to count the average load, we counted the number of people every 5 seconds, and averaged the statistics at the 1st, 5th and 15th minutes, thus forming the average load of the 1st, 5th and 15th minutes.
Some people pick up the phone and call for one minute, while others may be looking for the phone number in the first 30 seconds, or hesitate to call, and then make a real phone call in the next 30 seconds. If we think of the phone as a CPU and the number of people as a task, we say that the CPU utilization of the previous person (task) is high and the CPU utilization of the latter person (task) is low.
Of course, CPU will not work in the first 30 seconds and rest in the last 30 seconds, just that some programs involve a lot of calculations, so the CPU utilization rate is high, while some programs involve very few calculations, so the CPU utilization rate is naturally low. However, no matter whether the utilization of CPU is high or low, it has nothing to do with how many tasks are queued behind.
Fourth, knowing the meaning of CPU load, how can we reduce the CPU load on the server?
The easiest way is to replace the server with better performance, don't just think about improving the performance of CPU, that's useless, CPU needs other hardware and software to play its best performance.
When other aspects of the server are properly configured, both the number of CPU and the number of CPU cores (that is, kernels) will affect the CPU load, because tasks are eventually assigned to the CPU core to handle. Two CPU blocks are better than one CPU, and dual cores are better than single cores.
Therefore, we need to keep in mind that apart from the differences in CPU performance, the CPU load is calculated based on the number of kernels! There is a saying, "how many cores are there, that is, how much load there is."
5. So, how much of the CPU load is shared on each CPU at the beginning of this article? That depends on how many cores my server has.
There is a / proc directory in Linux, which stores the virtual mapping of the current running system, and one of the files is cpuinfo, which stores the information of CPU. We can directly open and view, or filter keywords to view, because the file content is more, so generally we need to filter keywords.
The / proc/cpuinfo file displays information in paragraphs by logical CPU rather than the real CPU, with each logical CPU's information occupying a paragraph, with the first logical CPU logo starting at 0. First of all, we need to understand this, as to what is logical CPU, which will be mentioned below. To understand the CPU information in this file, there are several related concepts to know:
Processor: identification of the logical CPU
Model name: model information of the real CPU
Physical id: real CPU and logo
Cpu cores: the number of cores of the real CPU
$> grep 'model name' / proc/cpuinfo | uniq
Model name: Intel (R) Xeon (R) CPU E5320 @ 1.86GHz
$> grep 'physical id' / proc/cpuinfo | sort | uniq | wc-l
two
$> grep 'cpu cores' / proc/cpuinfo | uniq
two
As you can see, the CPU model of the server is Intel (R) Xeon (R) CPU E5320, dual CPU, and each CPU is dual core, which is equivalent to four cores of the server.
We said earlier that the CPU load is calculated based on the number of CPU cores, so for example, the average load in the previous 15 minutes is 10.49. we can find that the load of this server is 5.245 per CPU, and then distributed to the kernel, the load per kernel is about 2.6.
Is this load reasonable? That depends on what the standard of the ideal CPU load looks like.
6. What is the ideal CPU load?
This is controversial, each has its own view, I personally agree that the CPU load less than or equal to 0.7 is an ideal state.
No matter how good the performance of a CPU is and how many tasks it can handle in a second, we can assume that it doesn't matter, even though it's not. When evaluating the CPU load, we only count the task queue length in 5 seconds. If the task queue length is found to be 1 every 5 seconds, then the CPU load is 1. If we only have a single-core CPU and the load is always 1, it means there are no tasks queuing up, which is not bad.
The server I mentioned above is dual-core and CPU, which is equal to four cores. If the load of each kernel is 1, the total load is 4. That is to say, if the CPU load on my server stays around 4 for a long time, it's acceptable. But in fact, the CPU load has reached more than 9, so it is troublesome.
But the load of each kernel is 1, which is not an ideal state! This means that our CPU has been very busy and can not be idle. It is said on the Internet that the ideal state is that the load of each kernel is about 0.7. I agree that the ideal CPU load of the server can be obtained by multiplying the number of cores within 0.7. for example, for my server, the load is less than 3.0.
7. The following descriptions of logical CPU are all from the Internet:
Today's servers generally use "Hyper-Threading" (HT) technology to improve the performance of CPU. Hyper-threading technology is that a CPU executes multiple programs at the same time while sharing resources in a CPU. In theory, it is like two CPU executing two threads at the same time.
Although hyper-threading technology can execute two threads at the same time, it is not like two real CPU, each CPU has independent resources. When both threads need a resource at the same time, one of them temporarily stops and gives up the resource until the resource is idle. Therefore, the performance of hyperthreading is not equal to the performance of two CPU.
CPU with hyper-threading technology has some other limitations.
Thank you for your reading, the above is the content of "what is the CPU load in linux". After the study of this article, I believe you have a deeper understanding of what the CPU load in linux is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.