CPU for Linux performance monitoring

Source: Internet
Author: User
Article Title: CPU for Linux performance monitoring. 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.

As we discussed earlier, the performance of any system is baseline-based, and the performance of CPU monitoring is the above three points. The running queue, CPU usage, and context switching are supported. The following are common performance requirements for Linux performance monitoring CPUs:

Linux performance monitoring CPU

1. For each CPU, the running queue should not exceed 3. For example, if it is a dual-core CPU, it should not exceed 6;

2. If the CPU is running at full capacity, it should meet the following distribution,

A) User Time: 65% ~ 70%

B) System Time: 30% ~ 35%

C) Idle: 0% ~ 5%

3. Context switching depends on CPU usage. If the CPU usage meets the preceding distribution, a large number of context switches are acceptable.

Common monitoring tools include vmstat, top, dstat, and mpstat.

# Vmstat 1

Procs ----------- memory ---------- --- swap -- ----- io ---- system -- ---- cpu ----

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

0 0 104300 16800 95328 72200 0 0 5 26 7 14 4 1 95 0

0 0 104300 16800 95328 0 0 0 24 72200 64 1 1 98 0

0 0 104300 16800 95328 0 0 0 0 72200 59 1 1 98 0

R indicates the size of the running queue,

B indicates the number of threads in the block due to IO wait,

In indicates the number of interrupts,

Cs indicates the number of context switches,

Us indicates the user's CPU time,

Sys indicates the system CPU time,

Wa indicates the time when the CPU is in the idle state due to IO wait,

Id indicates the total time when the CPU is in the idle state.

Dstat provides the number of disconnections generated by each device:

# Dstat-cip 1

---- Total-cpu-usage ---- interrupts --- procs ---

Usr sys idl wai hiq siq | 15 169 185 | run blk new

6 1 91 2 0 0 | 12 0 13 | 0 0 0

1 0 99 0 0 0 | 0 0 6 | 0 0 0

0 0 100 0 0 0 | 18 0 2 | 0 0 0

0 0 100 0 0 0 | 0 0 3 | 0 0 0

We can see that there are 3 device numbers 15,169 and 185. For the relationship between the device name and the device number, refer to the file/proc/interrupts. Here 185 represents the network card eth1.

# Cat/proc/interrupts

CPU0

0: 1277238713 IO-APIC-edge timer

6: 5 IO-APIC-edge floppy

7: 0 IO-APIC-edge parport0

8: 1 IO-APIC-edge rtc

9: 1 IO-APIC-level acpi

14: 6011913 IO-APIC-edge ide0

15: 15761438 IO-APIC-edge ide1

169: 26 IO-APIC-level Intel 82801BA-ICH2

185: 16785489 IO-APIC-level eth1

193: 0 IO-APIC-level uhci_hcd: usb1

Mpstat can display the running status of each CPU. For example, the system has four CPUs. We can see that:

# Mpstat? P all 1

Linux 2.4.21-20. ELsmp (localhost. localdomain) 05/23/2006

05:17:31 CPU % user % nice % system % idle intr/s

05:17:32 PM all 0.00 0.00 3.19 96.53 13.27

05:17:32 PM 0 0.00 0.00 0.00 100.00 0.00

05:17:32 PM 1 1.12 0.00 12.73 86.15

05:17:32 PM 2 0.00 0.00 0.00 100.00 0.00

05:17:32 PM 3 0.00 0.00 0.00 100.00 0.00

To sum up, Linux performance monitoring includes the following:

Check the running queue of the system to ensure that the running queue of each CPU is no greater than 3. Ensure that the CPU usage distribution meets the 70/30 principle (user 70%, system 30% ). If the system takes too long, it may be because of frequent scheduling and priority changes. CPU Bound processes are always punished (lower priority), while IO Bound processes are always rewarded (higher priority ).

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.