In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the relationship between CPU utilization and machine load under Linux". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what is the relationship between CPU utilization and machine load under Linux"?
When we use the top command to view the resource usage of the system, we will see load average, as shown in the following figure. It represents the average workload of the system at 1, 5, and 15 minutes. So what is load? What does it have to do with the utilization of CPU?
Load average: the average system load is the Load of CPU. The information it contains is not the utilization status of CPU, but the statistics of the total number of processes that CPU is working on and waiting for CPU to process over a period of time, that is, statistics on the length of queues used by CPU. The smaller the number, the better.
01. The difference between CPU load and CPU utilization
CPU utilization: shows the percentage of real-time CPU occupied by the program while it is running
CPU load: shows the average number of tasks in use 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. For example: if I have a program that needs to use the computing function of CPU all the time, then the utilization rate of CPU may reach 100%, but the workload of CPU tends to be "1", because CPU is only responsible for one job! What if you execute two such programs at the same time? the utilization rate of CPU is still 100%, but the workload becomes 2. So that is to say, when the workload of CPU is larger, it means that CPU must switch between different jobs frequently.
Examples are as follows:
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 count the number of people every 5 minutes, and take the average of 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.
02. What is the ideal load?
This is controversial, each has its own view, I agree that the CPU load less than or equal to 0.5 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 minutes. If the task queue length is found to be 1 every 5 minutes, 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.
But my server, which is dual-core and CPU, 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 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.
03. How to reduce the CPU load of 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 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."
04. What is the ideal utilization rate of CPU?
In the past, CPU utilization was often regarded by us laymen as a criterion to judge whether the machine has reached full load. When I see a long-term CPU utilization rate of 60-80%, I think there is a bottleneck in the machine.
At this point, I believe you have a deeper understanding of "what is the relationship between CPU utilization and machine load under Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.