Understanding cpu system load in Linux

Source: Internet
Author: User

Understanding cpu system load in Linux

1. View System Load

If your computer is slow, you may want to check whether it is too heavy.

In Linux, we generally use the uptime command to view (w command and top command ). (They also apply to Apple's Mac computers .)

If you type uptime in the terminal window, the system will return a line of information.

The second half of this line shows "load average", which means "average system load". There are three numbers, from which we can determine whether the system load is large or small.

Why is there three numbers? You can see from the manual that they mean the average load of the system within 1 minute, 5 minutes, and 15 minutes.

If you continue reading the manual, it will tell you that when the CPU is completely idle, the average load is 0; when the CPU workload is saturated, the average load is 1.

Obviously, the lower the value of "load average", such as 0.2 or 0.3, indicates that the smaller the computer workload, the lighter the system load.

But when can we see that the system load is heavy? When 1 is equal to 0.5 or 1.5? What if the values of 1 minute, 5 minutes, and 15 minutes are different?

2. An analogy

To determine whether the system load is too heavy, you must understand the true meaning of load average. Next, I try to explain this problem in the most popular language according to the article "Understanding Linux CPU Load.

First, assume that your computer has only one CPU, and all the operations must be completed by this CPU.

We may think of this CPU as a bridge with only one driveway and all vehicles must pass through the driveway. (Obviously, this bridge can only be used for one-way access .)

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

The system load is 0.5, which means there is a car in half of the road section of the bridge.

The system load is 1.0, which means that all sections of the bridge have cars, that is, the bridge is full. However, it must be noted that the bridge can still pass smoothly until now.

The system load is 1.7, which means there are too many vehicles, the bridge is full (100%), and the vehicles waiting for the bridge are 70% of the bridge deck vehicles. Similarly, the system load of 2.0 means that the number of vehicles waiting for the bridge is the same as that of the bridge deck. The system load of 3.0 means that the number of vehicles waiting for the bridge is twice that of the bridge deck. In short, when the system load is greater than 1, the rear of the vehicle must wait; the larger the system load, the longer the bridge must wait.

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

If the CPU processes a maximum of 100 processes per minute, the system load is 0.2, which means that the CPU only processes 20 processes in this minute; the system load is 1.0, this means that the CPU handles 100 processes in the past minute. The system load is 1.7, which means that in addition to the 100 processes that the CPU is processing, 70 processes are waiting in queue for CPU processing.

In order for the computer to run smoothly, it is recommended that the system load not exceed 1.0, so that no process needs to wait, and all processes can be processed immediately. Obviously, 1.0 is a key value. If this value is exceeded, the system will not be in the optimal state. You have to intervene.

Iii. empirical rules of system load

Is 1.0 an ideal value for system load?

Not necessarily, the system administrator may leave a little room. When the value reaches 0.7, it should be noted. The rule of thumb is as follows:

When the system load continues to exceed 0.7, you must begin to investigate where the problem is, to prevent the situation from deteriorating.

When the system load continues to exceed 1.0, you must find a solution to reduce this value.

When the system load reaches 5.0, it indicates that your system has a very serious problem, does not respond for a long time, or is close to the dead. You should not allow the system to reach this value.

4. multi-processor

We assume that your computer has only one CPU. What happens if two CPUs are installed on your computer?

Two CPUs means that the computer's processing capability has doubled, and the number of processes that can be simultaneously processed has also doubled.

In comparison with the bridge, the two CPUs mean that the bridge has two lanes, and the opening capacity doubles.

Therefore, two CPUs indicate that the system load can reach 2.0, and each CPU has a workload of 100%. To promote it, computers with n CPUs have an acceptable system load of up to n.0.

V. multi-core processors

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

In terms of system load, the multi-core CPU and multi-CPU performance are similar. Therefore, when considering the system load, you must consider how many CPUs 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 runs normally.

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

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

For example:

* ***** CPU Information ******

Cpu model: 40 Intel (R) Xeon (R) CPU E5-2680 v2 @ 2.80 GHz

Logical cpu count: 40

Number of physical CPUs: 2

Number of cores per physical CPU: 10 ---- the computer runs normally if the load does not exceed 20

(Whether hyper-threading is supported. If hyperthreading is greater than 1, it indicates support.): 2

Memory: 64375 MB

*****************************

[Root @ HaoDai_App_DB01 toolsqldir] # uptime

10:02:08 up 207 days, 1 user, load average: 6.37, 5.34, 4.93

6. Optimal observation duration

The last question is, "load average" returns three average values: one-minute system load, five-minute system load, and 15-minute system load. Which value should I refer?

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

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

This article permanently updates the link address:

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.