Performance Analysis Linux Server CPU utilization

Source: Internet
Author: User
Tags time interval

1. Indicator Range 1.1 User mode CPU utilization+ System Mode CPU Utilization

Reasonable value: 60-85%, if the us+sy time in a multiuser system exceeds 85%, the process may take time to wait in the running queue, the response time and business throughput will be compromised; the US is too large to indicate that there is a user process that consumes a lot of CPU time, and further analysis of other hardware and software factors is required; sy too large , it shows that the system management has spent a lot of time, indicating that a subsystem in the system has a bottleneck and needs further analysis of other hardware and software factors.

1.2 Wa (Wait)

Reference value: Less than 25%, the value of more than 25% WA can indicate that the disk subsystem may not be properly balanced, or it may be the result of a disk-intensive workload, a system disk or other I/O may have problems, can be further decomposed by the IOSTAT/SAR–C command analysis

1.3 Id (Idle)

Reference value: Greater than 40, if R is often greater than 4, and the ID is often less than 40, indicating a heavy load on the CPU

1.4 R

Reference value: Less than 4, the queue is greater than 4 o'clock, indicates that the system CPU or memory may be a problem, if R is often greater than 4, and the ID is often less than 40, indicating that the CPU load is heavy. When the queue becomes longer, the process in the queue takes longer to wait for the CPU to schedule execution

1.5 ways to determine CPU bottlenecks

Very slow response times (slow response time)

CPU idle time is 0 (zero percent idle CPU)

Excessive user consumption CPU time (high percent user CPU)

Excessive CPU time (high percent system CPU)

Long running process queue (large run queue size sustained over time)

2. How to view CPU Utilization 2.1 Use the top command to view

Data from/proc/stat file

%us = (User time + nice times)/cpu *100%

%sy= (System time + HARDIRQ)/CPU times *100%

%id= (Idle)/cpu time *100%

%ni= (Nice time)/cpu *100%

%wa= (Waiting time)/cpu *100%

%hi= (Hardirq time)/cpu *100%

%si= (Softirq time)/cpu *100%

%st= (Steal time)/cpu *100%

Note: The top command is refreshed every 3 seconds by default. You can also specify the refresh frequency, such as top-d 0.1 or top-d 0.01, by top-d < refresh interval >. When top is executed, you can also press the "s" key to modify the time interval.

2.2 Using Vmstat to view

R indicates the size of the running queue, B indicates the number of threads in the block due to Io waits, in represents the number of interrupts, and CS represents the number of context switches.

2.3 Other ways to view

Iostat, Sar-q, sar–u, etc.

3. CPU Introduction 3.1 time in the kernel

Hz is the number of times the system clock is fixed to make a clock interrupt within one second. Hz can be configured before compiling the kernel, so you can see the current system's clock interrupt frequency with the following command: cat/boot/config-' uname-r ' | grep config_hz

Tick is the time that the system clock ticks every tick, with a value of (1/hz) seconds. That is, the time interval between two consecutive clock interrupts.

The jiffies is used to calculate the number of ticks since the start of the system, which means that the value of the variable is incremented once each time the clock is interrupted by the system clock.

3.2 CPU Time composition

The working time of CPU is composed of three parts: User state time, System state time and idle state time. The specific composition is:

The CPU time includes user, System, nice, Idle, waiting, HARDIRQ, SOFTIRQ, Steal

Idle state ==idle Time

User state time ==user time+ nice times.

Kernel state time ==system time+ HARDIRQ time+ SOFTIRQ.

User Time. Refers to the time that the CPU executes the process in the user state.

System time. Refers to the time that the CPU is running in the kernel.

Nice time. Refers to the time that the system spends adjusting the process priority.

Idle time. The system is in an idle period and waits for the process to run.

Waiting time. The total time that the CPU spends waiting for I/O operations, similar to blocked.

Steal time. Refers to the amount of time that the current CPU is forced (involuntary wait) to wait for another virtual CPU to finish processing, at which point Hypervisor is serving another.

Softirq time, Hardirq time. Corresponds to the CPU time that the system spends dealing with soft and hard interrupts, respectively.

3.3 User Mode CPU utilization

%usr. Shows the percentage of CPU time that is spent in the user's way, the process by which the user uses the CPU: the CPU runs a regular user process, and the CPU runs niced PROCESS,CPU runs the real-time process. A Linux process can be executed in the user mode, or in the system (kernel) mode, when a process runs in kernel code, we call it in the kernel state, when a process is executing the user's own code, we call it in the user state, when executed in user mode, The process executes in its own application code and does not require kernel resources to compute, manage memory, or set variables

3.4 System Mode CPU Utilization

Shows the percentage of CPU time that is spent in system mode, including the CPU resources consumed by kernel processes (Kprocs) and other processes that require access to the kernel resources, the processes that the system uses for CPU include: For system calls, for I/O management (interrupts and drives), for memory management (paging and Swapping), used for process management (context switch and process start), if a process requires kernel resources, it must perform a system call and switch to system mode to make the resource available.

3.5%wa (Wait)

Shows the percentage of CPU idle for standby local disk I/O and NFS loaded disks, which is the rate at which the CPU is idle due to the process waiting for I/O, mainly including:block I/o,raw i/o,vm-paging/swapins. If there is at least one outstanding disk I/O during the wait run, the event is classified as I/O wait time, the I/O request to the disk causes the calling process to block (or sleep) until the request is complete, and the process is placed in the run queue once the process's I/O request completes. If I/O is completed quickly, the process can use more CPU time.

3.6%id (Idle)

In addition to idle conditions above wio, the percentage of time that the CPU is idle or waiting is shown when there is no local disk I/O. If no thread can execute (the run queue is empty), the system assigns a thread called wait, which can be called an idle kproc. If the PS report shows that the total time for this thread is high, this indicates that there is a time period where no other threads are ready to run on the CPU or wait for execution. The system therefore spends most of its time idle or waiting for new tasks.

3.7 R (Runq-sz)

The length of the running process queue. These processes are ready in memory for the size of the number of processes that can run

Performance Analysis Linux Server CPU utilization (RPM)

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.