View the load in Linux and in Linux

Source: Internet
Author: User

View the load in Linux and in Linux

Bridge

A single-core processor can look like a single lane. Imagine that you now need to charge a bridge fee for this road-busy with handling the vehicles that will bridge the road. First of all, you need to know more information, such as the load of a vehicle and how many vehicles are waiting for crossing the bridge. If no vehicle is waiting, you can tell the driver to pass. If there are a large number of vehicles, You need to inform them that it may take a while.

Therefore, some specific codes are required to indicate the current traffic conditions, such:

0.00 indicates that there is no traffic flow on the current bridge deck. In fact, this situation is the same as that between 0.00 and 1.00. In short, it is very smooth and vehicles in the past do not have to wait for the vehicle to pass.

1.00 indicates that it is within the bearing range of the bridge. This is not a bad situation, but traffic may be blocked, but this may cause slower and slower traffic.

If the traffic exceeds 1.00, it indicates that the bridge has exceeded the load and serious traffic congestion. How bad is the situation? For example, the 2.00 case indicates that the traffic flow has already doubled beyond the bridge's capacity, so there will be vehicles that are twice as busy as they are waiting. 3.00 is even worse, it means that the bridge is basically unable to handle it, and there are more than twice the load of the bridge.

The above situation is very similar to the processor load. The bridge time of a car is like the actual time when the processor processes a thread. The Unix system defines the process running duration as the processing time of all processor kernels plus the waiting time of threads in the queue.

Like the administrator who receives the bridge fee, you certainly hope your car will not be waiting anxiously. Therefore, ideally, the average load is less than 1.00. Of course, it is not ruled out that part of the peak value will exceed 1.00. However, if you keep this status for a long time, it means there will be problems. At this time, you should be very anxious.

"So what do you say is the ideal load of 1.00 ?"

Well, this is not exactly the case. Load 1.00 indicates that the system has no remaining resources. In actual situations, experienced System Administrators place this line at 0.70:

"Requires investigation rules": if your system load is around 0.70 for a long time, you need to spend some time understanding the cause before it gets worse.

"Now we need to repair the rule": 1.00. If your server system load lingers at 1.00 for a long time, you should solve this problem immediately. Otherwise, you will receive a call from your boss in the middle of the night. This is not a pleasant task.

"Exercise at half past three a.m.": 5.00. If your server load exceeds 5.00, you will lose your sleep, and you have to explain the cause in the meeting. In short, never let it happen.

So what about multiple processors? My mean value is 3.00, but the system is running normally!

Wow, you have four processor hosts? Therefore, the average load is 3.00.

In a multi-processor system, the average load is determined by the number of kernels. In 100% load computing, 1.00 represents a single processor, while 2.00 represents two dual processors, so 4.00 indicates that the host has four processors.

Return to our metaphor for crossing the bridge. 1.00 I said it was a "one-lane road ". In the 1.00 case of a single lane, it indicates that the bridge has been filled with cars. In a dual-processor system, this means that the load is doubled, that is, there are still 50% of the remaining system resources-because there are other lanes available.

Therefore, when a single processor is under load, the full load of the dual processor is 2.00, and it has twice the resource available.


Multi-core and multi-processor

Let's take a look at the differences between a multi-core processor and a multi-processor. From the perspective of performance, a master machine with multiple cores can basically be considered as having the same number of processing performance as another one. Of course, the actual situation will be much more complicated. Different Quantities of cache, processor frequency and other factors may cause performance differences.

However, even if the actual performance of these factors is slightly different, the system still calculates the average load based on the number of cores of the processor. This gives us two new rules:

"How many cores is the load" rule: in multi-core processing, your system average value should not be higher than the total number of processor cores.

"Core" principle: it is not important that the core is distributed in several physical processes. In fact, two quad-core processors are equal to four dual-core processors and eight single-core processors. Therefore, it should have eight processor kernels.


Let's take a look at the uptime output.

~ $ Uptime

Up 14 days, 7 users, load averages: 0.65 0.42 0.36

This is a dual-core processor. The result also shows that there are a lot of idle resources. The actual situation is that even if its peak value reaches 1.7, I have never considered its load problems.

So how can there be three numbers that are really disturbing. We know that 0.65, 0.42, and 0.36 respectively indicate the average system load for the last minute, the last five minutes, and the last fifteen minutes. This raises another problem:

Which number shall we use? One minute? Five minutes? Or 15 minutes?

In fact, we have talked a lot about these numbers. I think you should focus on the average value of five or fifteen minutes. Frankly speaking, if the load in the previous minute is 1.00, it can still indicate that the server is still normal. However, if the value remains at 1.00 in 15 minutes, it is worth noting (based on my experience, you should increase the number of processors at this time ).

So how do I know how many core processors my system is equipped?

In Linux, you can use

Cat/proc/cpuinfo

Obtain information about each processor on your system. If you only want numbers, use the following command:

Grep 'model name'/proc/cpuinfo | wc-l

Popularity: 11% [?]



1. cat/proc/loadavg

0.27 0.36 0.37 4/83 4828/

Parameter description

1. Average load: 0.54, 0.40, 0.20

System load in the last 1 minute, 5 minutes, and 15 minutes

2. Number of processes: 4/83

The numerator is the number of running processes, and the denominator is the total number of processes.

3. Process number: 4828

ID of the recently running process


2. uptime
Name: uptime
Permission: All Users
Usage: uptime [-V]
Note: The uptime provides the following user information without other parameters:
The number of users connected to the current time when the system starts up and goes through the last minute, five minutes and fifteen minutes of system load
Parameter:-V displays version information.
Example: uptime
The result is:
Am up 5 days, 10 min, 1 users, load average: 0.00, 0.00, 1.99

Parameter description

1. 04:03:58 current time

2. The system has been running for 10 days

3. Former online user 1 user

4. Average load: 0.54, 0.40, 0.20

System load in the last 1 minute, 5 minutes, and 15 minutes


The/proc/uptime file contains two numbers, for example:

[Root @ localhost ~] # Cat/proc/uptime
1232468.44 1111331.67

The first value indicates the total start time of the system, and the second value indicates the idle time of the system, which is expressed in seconds. If the second number in the system is larger than the first number, it means that your cpu is multi-core, cpu 0 is idle for one second, cpu 1 is idle for two seconds, and the addition is three seconds.


3. w
Function Description: displays the user information currently logged on to the system.
Syntax: w [-fhlsuV] [user name]
Note: If you execute this command, you can find out who are currently logged on to the system and the programs they are executing. Run w
The command displays all users. You can also specify a user name to display only information about a user.
Parameters:
-F. enable or disable the function to show where the user logs on to the system.
-H: The title information column of each column is not displayed.
-L use the detailed format list, which is the default value.
-S uses a concise format list, which does not display the User Logon Time, CPU time consumed by terminal jobs and programs.
-U ignores the name of the execution program and the CPU time consumed by the program.
-V displays the version information.
4. top
Function Description: displays and manages programs in execution.
Syntax: top [bciqsS] [d <interval seconds>] [n <execution times>]
Note: Execute the top command to display the programs currently being executed in the system, and manage them using hotkeys through the interactive interface provided by it.
Parameters:
B uses the batch processing mode.
C. When listing programs, the complete commands of each program are displayed, including the command name, path, parameters, and other information.
D <interval seconds> set the interval between the execution status of the top monitor, measured in seconds.
When I run the top Command, ignore idle or Zombie programs.
N <execution count> set the number of metric information updates.
Q: continuously monitors program execution status.
S uses the confidential mode to eliminate potential crisis in the interactive mode.
S uses the accumulative mode. The effect is similar to the "-S" parameter of the ps command.

5. tload
Function Description: displays the system load status.
Syntax: tload [-V] [-d <interval seconds>] [-s <scale size>] [terminal number]
Note: The tload command uses ASCII characters to display the System Load Status in text mode. If no terminal number is assigned, the load is displayed on the terminal that executes the tload command.
Parameters:
-D <interval seconds> sets the interval between tload and system load detection, measured in seconds.
-S <scale size> sets the vertical scale of the chart. The unit is calculated in columns.

-V displays the version information.

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.