Operating System performance monitoring-CPU usage

Source: Internet
Author: User

CPU usage is divided into

    1. User-configured CPU usage: The percentage of time that the application code was executed in total CPU time
    2. System-State CPU Usage: Percentage of total CPU time that the application performed operating system calls

System-State CPU usage means that there is a competition for shared resources or that there is a lot of interaction between IO devices.

Goal: Ideal applications achieve maximum performance and scalability with system-State CPU utilization of 0%, providing application performance and scalability one goal is to minimize system-state CPU usage

For compute-intensive applications

    1. Monitor user Configuration and System State CPU usage
    2. Monitor per-clock instruction book IPC or CPI per instruction clock cycle (important for compute-intensive, system-brought tools cannot be monitored)

Stagnation: The CPU waits for data in memory, and the operating system tool still reports that the CPU is busy, which occurs when the operation data used by the instruction is not in the register or in the cache.

Goal: Reduce latency or improve CPU cache usage, thus reducing the CPU's wasted clock cycles while waiting for memory data

Observe the CPU Usage tool

Vmstat: Can only view overall CPU usage

    1. US: Percentage of user Process execution time. when the value of us is higher, it means that the user process consumes more CPU time, but if it is used over a long period of 50%, then we should consider optimizing the program algorithm or accelerating
    2. Sy: Percentage of kernel system process execution time. when the value of SY is high, it indicates that the system kernel consumes more CPU resources, this is not a benign performance, we should check the cause
    3. The percentage of Wa:io waiting time. when the value of WA is high, the IO Wait is serious, which may be caused by random access to the disk, or it may be a bottleneck
    4. ID: Percentage of idle time

Mpstat: Handling Related statistics

Mpstat [- p { CPU | All } ] [ -v ] [ interval [ Count ] ]

View all CPU statistics, once every 2 seconds

    • CPU:CPU number
    • %user: The percentage of CPU time that is consumed by user-level processes (applications) during the monitored interval.
    • %nice: The percentage of CPU time consumed by a user-level process that has a negative nice value during the monitored interval.
    • %sys: The CPU usage that is consumed by the system and the process (kernel) during the monitored time interval. This time includes the time it takes for the system to handle soft and hard interrupts.
    • %iowait: The percentage of CPU idle time that waits for the hard disk I/o during the monitored interval.
    • %IRQ: The percentage of time that the CPU service has been hard-interrupted during the monitored time interval.
    • %soft: The percentage of time that the CPU service has been soft-interrupted during the monitored time interval.
    • %idle: The percentage of time that the CPU is idle during the monitored interval, excluding the time it takes to wait for the disk IO request.

CPU Scheduler Run queue

Role: Monitoring the CPU Scheduler run queue is used to tell if the system is full load.

Run queues: Lightweight processes that are ready to run and are waiting for available CPUs.

If the number of lightweight processes that are ready to run exceeds the limit that the system can handle, the run queue can be very long. When the system is running a queue equal to the number of virtual machine processors, the user does not noticeably experience performance degradation. (The virtual processor is the number of system hardware threads.) Runtime.availableprocessors () return value). The system responds very slowly when the run queue length reaches 4 times times or more of virtual processing.

guiding principle : If a long time, the length of the running queue has been more than 1 time times the number of virtual processors, it is important to pay attention to, if a long time, the running queue length reached 3-4 times the number of virtual processors or higher, need immediate attention or take action.

How to Solve

    1. Increase the CPU, share the load or reduce the processor load and fundamentally solve it.
    2. Analyze the applications running in the system to improve CPU utilization. Solve algorithm and data structure efficiency

On-line Vmstat 1 observing CPU queue condition

Procs

    • r: Number of processes waiting in the run queue
    • B: Number of processes waiting on Io

Mpstat view CPU count and CPU usage, system load is slightly higher

CPU-related monitoring and introduction.

Reference:

Http://www.ha97.com/4512.html

Http://linuxcommand.org/man_pages/vmstat8.html

Operating System performance monitoring-CPU usage

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.