How to view CPU load on Linux

Source: Internet
Author: User

Which tools can view CPU load?

You can use the top command, the uptime command, and especially the top command, to be powerful, not just to see the CPU load.

How is CPU load understood? is CPU utilization not?

To differentiate 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 that the program consumes in real time during runtime, while the CPU load shows the average number of tasks that are in use and waiting for the CPU over time. High CPU utilization does not mean that the load is necessarily large. There is an interesting analogy on the internet, and call to explain the difference between the two, I explained in my own understanding. A public telephone kiosk, there is a person on the phone, four people waiting, each limit the use of the phone for one minute, if someone does not finish the phone within a minute, can only hang up the phone line, waiting for the next round. The phone is the equivalent of the CPU, and the person who is or is waiting for the call is the equivalent of the task. In the use of telephone booths, it is certain that someone will be out of the phone, some people do not call and choose to re-queue, there will be new people in the line here, the number of changes is equivalent to the number of tasks increase or decrease. To count the average load, we counted the number of people for 5 seconds and averaged the statistics at 1th, 5, 15 minutes, resulting in an average load of 1th, 5 and 15 minutes. Some people pick up the phone to play, has been playing 1 minutes, and some people may be in the first 30 seconds to find the phone number, or hesitate to play, after 30 seconds is really on the phone. If you think of the phone as a CPU, the number of people as a task, we say the previous person (Task) CPU utilization is high, the latter one (Task) CPU utilization is low. Of course, the CPU does not work in the first 30 seconds, after 30 seconds to rest, just said, some programs involve a lot of computation, so CPU utilization is high, and some programs involved in the calculation of the few, CPU utilization is naturally low. However, regardless of the CPU utilization is high is low, with the number of tasks behind the queue does not necessarily have a relationship.

How to reduce the CPU load of the server?

The simplest way is to replace the better performance of the server, do not want to just improve the performance of the CPU, it is not used, the CPU to play its best performance also requires the coordination of other hardware and software. In other aspects of the server configuration, the number of CPUs and CPU cores (that is, the number of cores) will affect the CPU load, because the task is ultimately allocated to the CPU core to be processed. Two CPUs are better than one CPU, and dual cores are better than single cores. Therefore, we need to keep in mind that the CPU load is calculated based on the number of cores, except for the difference in CPU performance! There is a saying, "How many cores, that is, how much load".

How much CPU load is ideal?

The individual agrees that a CPU load of less than or equal to 0.7 is considered an ideal state. No matter how good the performance of a particular CPU is, how many tasks can be handled in 1 seconds, we can think of it as irrelevant, although that is not the case. When we evaluate the CPU load, we only count the task queue length in 5 seconds. If the task queue length is 1 when counted every 5 seconds, the CPU load is 1. If we only have a single-core CPU, the load is always 1, which means that no task is queued and not bad. The above-mentioned server, which is a dual-core CPU, equals 4 cores with a load of 1 per core, and a total load of 4. This means that if my server's CPU load remains around 4 for a long time, it can be accepted.  But in fact the CPU load has reached more than 9, so it is very troublesome. But a load of 1 per core is not an ideal state! This means that our CPU is always busy and not idle. The network has said that the ideal state is about 0.7 of the load per core, I agree, 0.7 times the number of cores, the server ideal CPU load , such as I this server, load under 3.0 can be.

#查看CPU型号:

$>grep ' model name ' /proc/cpuinfo | Uniq

Model Name:intel (R) Xeon (r) CPU e5-2682 v4 @ 2.50GHz

#查看CPU物理个数

$>grep ' physical ID ' /proc/cpuinfo | Sort | Uniq | WC -l

0

#查看单个CPU是几核的

$>grep ' CPU cores ' /proc/cpuinfo | Uniq

 

How to view CPU load on Linux

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.