Correct cognition of%iowait and CPU usage

Source: Internet
Author: User

Resources
    • Understanding%iowait (%wio)
    • Linux system CPU utilization and load
    • Linux Performance Observability Tools
    • How Linux CPU Usage time and Percentage is calculated
    • Linux process status
Mans (on RHEL 7)
 # man mpstat%usr Show The percentage of CPUs utilization that occurred while execut ing at the user level (application).%nice Show The percentage of CPUs utilization that occurred and executing at th E User level with nice Priority.%sys Show the percentage of CPUs utilization that occurred while executing at the SYS TEM level (kernel). Note that this does not include time spent servicing hardware and software interrupts.  
%iowait Show The percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I  /O REQUEST.%IRQ Show the percentage of time spent by the CPU or CPUs to service hardware Interrupts.%soft show The percentage of time spent by the CPU or CPUs to service software interrupts.%steal Show The percentage of time s       Pent in involuntary wait by the virtual CPU or CPUs while the hypervisor is servicing another virtual Processor.%guest Show the percentage of time spent by the CPU or CPUs to run a virtual Processor.%gnice Show the percentage of T IME spent by the CPU or CPUs to run a niced guest.%idle Show the percentage of time that the CPU or CPUs were idle a nd the system did not has an outstanding disk I/O request.# man Topus, user:time running un-niced user Processessy, sys Tem:time running kernel Processesni, nice:time running niced user Processesid, Idle:time spent in the kernel idle ha Ndlerwa, Io-wait:timeWaiting for I/O completionhi:time spent servicing hardware interruptssi:time spent servicing software interruptsst:t IME stolen from this VM by the hypervisor
TIPS
    • CPU Usage Time and Percentage
Refer to the Mpstat manual,%usr +%nice +%sys +%iwoait +%IRQ +%soft +%steal +%guest +%gnice +%idle = 100%%steal Typically you can see values in a virtual machine, such as CPU overcommitment very serious VPS, while%guest and%nice are generally very low,
So can also be based on/proc/stat or top available, user + nice + system + Idle + iowait + IRQ + SOFTIRQ + steal = 100To calculate Linux CPU usage ti Me subtract the idle CPU time from the total CPU time as Follows:total CPU time since boot = user + nice + system + ID Le + iowait + IRQ + SOFTIRQ + stealtotal CPU idle time since boot = Idle + iowaittotal CPU usage time since boot = (to Tal CPU time since boot)-(total CPU Idle time since boot) total CPU Percentage = (Total CPU usage time since boot)/(T Otal CPU time since boot X 100)
    • Linux process status
Operating State (task_running):
is a combination of a run state and a ready state, indicating that the process is running or ready to run, and that using task_running macros in Linux means that this state can interrupt sleep (light sleep) (task_interruptible):
The process is sleeping (blocked), waiting for the resource to arrive to wake up, or it can wake up through another process signal or clock interrupt to enter the run queue. Linux uses task_interruptible macros to represent this state. Non-disruptive sleep state (deep sleep State) (task_uninterruptible):
It is basically similar to shallow sleep, but one thing is that it cannot be awakened by other process signals or clock interrupts. Linux uses task_uninterruptible macros to represent this state. Paused state (task_stopped):
The process pauses execution to accept some sort of processing. If the process undergoing debugging is in this state, Linux uses the task_stopped macro to represent this state. Zombie State (Task_zombie):
Process has ended but not released Pcb,linux use Task_zombie macro to represent this state
    • The correct cognition of%iowait
%iowait indicates that a percentage of the time in a sample period is the following: The CPU is idle and there is a i/O request that isstill not completed. 
There are two common misconceptions about%iowait:
One is to mistakenly think that%iowait indicates that the CPU is not working,
The second is to mistakenly think that%iowait indicates I/O has bottlenecks.

The first%iowait rise does not justify an increase in the number of processes waiting for I/O, nor does it justify the total waiting time for I/O.
For example, the I/O that occurs during a busy CPU time, regardless of the number of Io or less,%iowait will not change, when the CPU is busy, a portion of IO falls into the CPU idle period, causing%iowait to rise.
For example, the concurrency of IO is low, the%iowait is high, and the concurrency of Io is high,%iowait may be relatively low.
Visible%iowait is a very vague indicator, if you see%iowait rise, also need to check I/O volume has not increased significantly, avserv/avwait/avque and other indicators have not significantly increased, the application has not felt slow, if not, there is nothing to worry about.
    • To view CPU usage, the following Linux commands are recommended:
# top# Sar-u 1 * vmstat-n 1 * mpstat-p all 1 5
    • To view the value of load, the following Linux commands are recommended:
# top# uptime# sar-q 1 5

Correct cognition of%iowait and 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.