Explain what happened to the server--top tool
The system administrator needs to have a general understanding of the current server state before checking the server's detailed performance status. Top is a powerful tool to check the overall status of the server, through top can get the CPU, Memory, process run information, the following is the data display after running the top command:
top-20:08:09 up min, 1 user, load average:0.00, 0.02, 0.01 tasks:104 total, 1 running, 103 Sleepi ng, 0 stopped, 0 Zombie Cpu (s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0% hi, 0.0%si, 0.0%st mem: 3924700k total, 260016k used, 3664684k free, 13552k buf Fers swap: 4063224k total, 0k used, 4063224k free, 75816k cached PID U ser pr ni virt res SHR S%cpu%mem time+ COMMAND 6284 root& nbsp 20 0 15028 1308 r 0.3 0.0 0:00.03 top 1 root 20 0 193 1580 1268 s 0.0 0.0 0:01.80 init 2 root 20 0 0 0& nbsp 0 s 0.0 0.0 0:00.00 kthreadd 3 root rt 0 0 0& nbsp 0s 0.0 0.0 0:00.02 migration/0 4 root 20 0 0 0 0 s 0.0 0.0 0:00.00 ksoftirqd/0 5 root rt 0 0 0 0 s 0.0 0.0 0:00.00 migration/0 6 root rt 0 0&nbs P 0 0 s 0.0 0.0 0:00.00 watchdog/0 7 root rt 0 0 0 0 s 0.0 0.0 0:00.03 migration/1 8 root rt 0  ; 0 0 0 s 0.0 0.0 0:00.00 migration/1 9 root 20 0 0 0 0 s 0.0 0.0 0:00.00 ksoftirqd/1 root &NBSP ; rt 0 0 0 0 s 0.0 0.0 0:00.00 WATCHDOG/1
Monitor CPU performance with top
When using top to analyze server performance, the first thing to note is the load average, load average includes three information, referring to the last minute, the last 5 minutes, the last 15 minutes of the system average performance, the value of anchoring (anchor value) is 1.0. For a single-core CPU, when the anchoring value reaches 1.0, the system is busy, but the application can run normally, and no application is queued to wait for the CPU.
Note that the load average is the average performance of the system rather than the CPU, and it is possible that the load average is much higher than 1.0, but the CPU does not do any work, such as the system is busy waiting for I/O.
Making the system always working at anchor value of 1.0 may be good, but may not be necessary, so before judging the system to work at anchor Value 1.0 is good or bad, it requires the system administrator to gain a deeper understanding of the specific workload. For example, for the following two tasks:
Task 1:while true; do true; Done
Task 2:DD IF=/DEV/SDA Of=/dev/null
When Task 1 o'clock is executed, Task 1 will make one core utilization of the CPU reach 100%, anchor value will exceed 1.0, if the system CPU has only one core, then the system will be in full busy state, then the new process will not start again, will be queued in the queue, Until there is idle CPU resources.
When you execute Task 2 o'clock, Task 2 also causes anchor value to be greater than or equal to 1.0, but at this point the task is just waiting for I/O resources, and the CPU can still continue to use it for other processes.
If the system CPU is very busy and you need to go through the CPU line of the top command to drill down on what the system is doing, the CPU line provides the following CPU performance information:
| us |
The US represents the user space payload, and the applications that are typically run under user space are started by an end user, not run as root, which means that the application consumes high CPU when the US load is high. |
| Sy |
The SY represents the system space load, and the process normally running under system space is called by the operating system kernel, and normally the SY is not very high. |
| Ni |
NI represents the number of tasks that have been started to be adjusted with the nice command. |
| Id |
The ID indicates when the CPU is idle. |
| Wa |
WA indicates that the CPU is waiting for I/O, and if WA is more than 30 consecutive, this indicates a problem with the I/O channel associated with storage and network and needs to check network and storage performance issues. |
| Hi |
Hi indicates the CPU time used to process hardware terminals. |
| Si |
Si is related to software interrupts, usually some low-priority software terminals created by the kernel, and almost rarely encounters a high SI usage rate. |
| St |
ST is related to a virtualized environment in which, in some virtualized environments, the virtual Opportunity host operating system steals CPU time, and if this happens, St will have a usage rate, and if the usage is high, consider uninstalling the virtual machine from the server. |
Monitor memory performance with top
The mem line of the top command is related to memory and swap partitions, and the Mem line consists of five parameters:
| Total |
The total physical memory of the server. |
| Used |
The memory currently in use, including buffers and cache. |
| Free |
Memory not currently in use. |
| Buffers |
Buffer is related to the write cache used by the server, including the file system tables and the structure that some servers need to put in memory. All data that needs to be written to disk is first written to the write cache, and from the point of view of the end user, the application used by the user does not need to wait for data to be written. If the system needs more memory and cannot allocate from free memory, the write cache can be refreshed and the memory used by the write cache is used by other applications. In summary, buffer makes the system faster. |
| Cached |
When a user requests a file from the server, typically the file needs to be read from disk, because the disk is about 1000 times times slower than memory, so each time the file is fetched from the disk, it is placed in the cache to speed up the next read of the file. If the memory allocated to CAHCE needs to be used by other applications, the cache can be released immediately and added to free memory for use. For those servers that read a lot, the cache memory is usually very high, if the cache memory is less than 40% of total memory, then the server performance may be slow, you need to increase memory. |
| Swap |
Swap space simulates memory on the hard disk, which is not good if the system starts to use swap, because swap is about 1000 times times slower than memory. But swap is not always bad, as the kernel uses it to remove unwanted data from memory in order to free up more memory space. |