Linux performance monitoring and tuning (CPU)

Source: Internet
Author: User
Article Title: Linux performance monitoring and tuning (CPU ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

In fact, there are many articles on this part on the Internet. Why is this article still available? There are several reasons why it is the motivation of my translation. First, although concepts and content are old-fashioned, but they are all very thorough and comprehensive. second, combining theory with practice, the case analysis is good. third, it is not fancy. The tools and commands used are the most basic and helpful for actual operations. however, I am not very familiar with the original text. Most of the translations are based on my understanding of the original text. You can also go to OSCAN to find the original text. If there is any major difference, I would like to send a message to you. I am very grateful!

1.0 performance monitoring

Performance optimization is to find the bottlenecks in system processing and remove these processes. Most administrators believe that performance optimization can be achieved by reading related "cook book, some kernel configurations can solve the problem simply, but are not suitable for each environment. performance optimization is actually a balanced definition of the various OS subsystems. These subsystems include:

CPU

Memory

IO

Network

These subsystems are mutually dependent, and any high load will cause problems in other subsystems. For example:

Memory queue congestion caused by a large number of page call requests

The large throughput of the NIC may cause more CPU overhead.

A large amount of CPU overhead will try more memory usage requests

A large number of disk write requests from memory may cause more CPU and IO problems.

Therefore, to optimize a system, it is critical to find out the bottleneck. Although it seems that a sub-system has a problem, it may be caused by other subsystems.

1.1 determine the application type

First of all, it is important to understand and analyze the features of the current system. Most systems run two types of applications:

IO Bound: Applications in this category are generally high-load memory usage and storage systems, which actually represent applications in the IO category, is a process of massive data processing. i/O applications do not initiate more requests to the CPU or network (unless network storage hardware such as NAS ). i/O applications usually use CPU resources to generate IO requests and enter the sleep status of kernel scheduling. usually database software (: mysql, oracle, etc.) is considered to be the application type in the IO category.

CPU Bound: Applications in this category are generally high-load CPU usage. the Application of CPU is a process of batch processing of CPU requests and mathematical computing. generally, web server, mail server, and other types of services are considered as CPU applications.

1.2 determine baseline statistics

The system utilization rate is generally determined based on the Administrator's experience and the purpose of the system. The only thing you need to know is what effect the system optimization hopes to achieve, what aspects need optimization, and what reference values are? Therefore, a baseline is established. The statistical data must be the available system performance status value to compare the unavailable Performance Status values.

In the following example, a baseline snapshot of system performance is used to compare the system performance snapshots at high loads.

# Vmstat 1

Procs memory swap io system cpu

R B swpd free buff cache si so bi bo in cs us sy wa id

1 0 138592 17932 126272 214244 0 0 1 18 109 19 2 1 96

0 0 138592 17932 126272 214244 0 0 0 105 46 0 1 0 99

0 0 138592 17932 126272 0 0 0 214244 62 40 14 0 45

0 0 138592 17932 126272 0 0 0 214244 49 0 0 117

0 0 138592 17924 126272 214244 0 0 176 220 3 4 13 80

0 0 138592 17924 126272 214244 0 0 0 358 8 17 0 75

1 0 138592 17924 126272 214244 0 0 0 368 4 24 0 72

0 0 138592 17924 126272 214244 0 0 0 352 9 12 0 79

# Vmstat 1

Procs memory swap io system cpu

R B swpd free buff cache si so bi bo in cs us sy wa id

2 0 145940 17752 118600 215592 0 1 1 18 109 19 2 1 96

2 0 145940 15856 118604 215652 0 0 468 789 86 14 0 0

3 0 146208 13884 118600 214640 0 360 360 71 91 9 0 0

2 0 146388 13764 118600 213788 0 340 340 41 87 13 0 0

2 0 147092 13788 118600 212452 0 740 1324 61 92 8 0 0

2 0 147360 13848 118600 211580 0 720 720 41 96 4 0 0

2 0 147912 13744 118192 210592 0 720 720 605 44 95 5 0 0

2 0 148452 13900 118192 209260 0 372 372 639 45 81 19 0 0

2 0 149132 13692 117824 208412 0 372 372 47 90 10 0 0

From the first result above, we can see that the last column (id) represents the idle time. We can see that during baseline statistics, the CPU idle time is between 79% and 100%. the second result shows that the system is in the 100% usage and there is no idle time. from this comparison, we can determine whether the CPU usage should be optimized.

[1] [2] [3] [4] Next page

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.