Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the Linux CPU load and CPU utilization

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

What is the Linux CPU load and CPU usage? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

CPU load and CPU utilization

Both of them can reflect the busy degree of a machine to some extent.

Cpu usage reflects the current busy level of cpu. The reason for the ups and downs is that the process that takes up cpu processing time may be in the io waiting state but has not yet been released into the wait.

Average load (load average) refers to the number of processes that occupy cpu time and the number of processes waiting for cpu time in a certain period of time. Here, processes waiting for cpu time refer to processes waiting to be awakened, excluding processes in wait state.

As can be seen from the above analysis, a machine is likely to be in a situation of low cpu utilization and high load, so the busy degree of the machine should be a combination of the two. From the actual usage, when the average load of a dual-core machine with 2.8GHz memory reaches about 50, the cpu utilization rate is close to 100% (applications have a lot of io operations). In this case, the application is smooth and the actual access delay is not very high. Therefore, when the cpu is still idle, how to improve the io response is the key to reduce the load. Many people think that the machine will be very busy when the load reaches dozens of times. I think that if the cpu utilization is relatively low at this time, the high load may not explain the problem very well. Once the cpu processing process is finished, those waiting processes can also be responded immediately. In this case, the io read and write speed should be optimized. It is true that the cpu utilization rate has been more than 90%, even if the average load is only single digits (for example, a certain process has been operating), the machine is already busy.

In fact, in the previous article, it was also written that the utilization rate of cpu is low and the load is high, and the reason is that the utilization rate of cpu is low, but the load is very high, and the one with high load may be IO.

An analogy of CPU load

To judge whether the system is overloaded or not, we must understand the true meaning of load average. Now, according to the article "Understanding Linux CPU Load", I will try to explain this problem in the most popular language.

First of all, suppose that in the simplest case, your computer has only one CPU, and all operations must be done by this CPU.

So, we might as well think of this CPU as a bridge with only one lane on which all vehicles must pass. It is obvious that the bridge can only be used in one way. )

The system load is 0, which means there are no cars on the bridge.

The system load is 0.5, which means that half of the bridge has cars.

The system load is 1.0, which means that all sections of the bridge have cars, which means the bridge is "full". However, it must be noted that the bridge can still pass smoothly up to this time.

The system load is 1.7, which means that there are too many vehicles, the bridge is already full (100%), and the vehicles waiting to get on the bridge behind are 70% of the vehicles on the bridge. By analogy, the system load 2.0 means that there are as many vehicles waiting to get on the bridge as there are on the bridge deck, while the system load 3.0 means that there are twice as many vehicles waiting for the bridge as there are on the bridge deck. In short, when the system load is greater than 1, the vehicles behind must wait; the greater the system load, the longer it will have to wait to cross the bridge.

The system load of CPU is basically the same as the above analogy. The capacity of the bridge is the maximum workload of CPU; the vehicles on the bridge are the processes waiting for CPU processing (process).

If CPU processes a maximum of 100 processes per minute, then the system load is 0.2, which means that CPU is only processing 20 processes in one minute; system load is 1.0, which means that CPU handles exactly 100 processes in one minute; and system load is 1.7, which means that in addition to the 100 processes being processed by CPU, there are 70 processes waiting in line for CPU processing.

In order for the computer to run smoothly, the system load had better not exceed 1.0, so that there are no processes to wait, and all processes can be processed the first time. Obviously, 1.0 is a key value, beyond which the system is not at its best and you need to intervene.

CPU load-multiprocessor

Above, we assume that your computer has only one CPU. What happens if you have two CPU installed on your computer?

Two CPU means that the processing power of the computer has doubled, and the number of processes that can be processed at the same time has doubled.

Still using the bridge as an analogy, two CPU means that the bridge has two lanes and its traffic capacity has doubled.

Therefore, 2 CPU indicates that the system load can reach 2.0, and each CPU reaches 100% of the workload. To generalize, the maximum acceptable system load for n CPU computers is n. 0.

CPU load-multicore processor

Chip manufacturers often have multiple CPU cores within one CPU, which is called multi-core CPU.

In terms of system load, the effect of multicore CPU is similar to that of multi-CPU, so when considering system load, you must consider how many CPU this computer has and how many cores each CPU has. Then, divide the system load by the total number of cores, as long as the load of each core does not exceed 1.0, it indicates that the computer is running normally.

How do you know how many CPU cores a computer has?

The "cat / proc/cpuinfo" command allows you to view CPU information. The "grep-c 'model name' / proc/cpuinfo" command directly returns the total number of cores of CPU.

Rule of thumb for system load

Is 1.0 the ideal value of system load?

Not necessarily, system administrators tend to leave a little leeway, and when this value reaches 0.7, it should be noticed. The rule of thumb goes like this:

When the system load continues to be greater than 0.7, you have to start investigating what the problem is to prevent the situation from getting worse.

When the system load continues to be greater than 1.0, you have to start looking for a solution to bring this value down.

When the system load reaches 5.0, it indicates that your system has a serious problem, has not responded for a long time, or is close to a crash. You should not let the system reach this value.

For my machine, there are 24 core, so how much load is appropriate?

[root@jiangyi01.sqa.zmf / home/ahao.mah/ALIOS_QA] # grep 'model name' / proc/cpuinfo | wc-L24

The answer is:

[root@jiangyi01.sqa.zmf / home/ahao.mah/ALIOS_QA] # echo "0.7: 24" | bc16.8

The best observation time

Last question, "load average" returns a total of three averages-1 minute system load, 5 minutes system load, 15 minutes system load,-which value should be referred to?

If only one minute of the system load is greater than 1.0, the other two time periods are less than 1.0, which indicates that it is only a temporary phenomenon and the problem is not big.

If the average system load is greater than 1.0 within 15 minutes (after adjusting the number of CPU cores), the problem persists, not temporarily. Therefore, you should mainly observe the "15-minute system load" and use it as an indicator of the normal operation of the computer.

!

Thank you for reading! After reading the above, do you have a general idea of Linux CPU load and CPU usage? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report