IOWait definition & properties
IOWait (usually labeled %wa in top) is a sub-category of idle (%idle is usually expressed as all idle except defined subcategories), meaning the CPU is not doing anything. Therefore, as long as there is another process that the CPU could be processing, it will do so. Additionally, idle, user, system, iowait, etc are a measurement with respect to the CPU. In other words, you can think of iowait as the idle caused by waiting for io.
Precisely, iowait is time spent receiving and handling hardware interrupts as a percentage of processor ticks. Software interrupts usually are labled separately as %si.
Importance & Potential misconception
IOWait is important because it often is a key metric to know if you’re bottlenecked on IO. But absense of iowait does not necessarily mean your application is not bottlenecked on IO. Consider two applications running on a system. If program 1 is heavily io bottlenecked and program 2 is a heavy CPU user, the %user + %system of CPU may still be something like ~100% and correspondingly, iowait would show 0. But that’s just because program 2 is intensive and relatively appear to say nothing about program 1 because all this is from the CPU’s point of view.
Tools to Detect IOWait
These are very basic tools often found in linux (if not all) systems. Some may require additional repos.
- top – This will be the simplest way in linux system. Just type “top”.
- iostat – More detailed with regarding to IO. Personally, I really thing the -x flag (extended) is quite essential. Part of sysstat package.
- iotop – like top but just for io.
- sar – This will display stats over history.
- Make sure that you have enough physical memory. If you run out of RAM and your OS starts to use the disk for cache, you will have a bad time.
- Defrag or keep sufficient space left in the drive. Any drive over 90% (roughly) will have difficulty preventing fragmentation of the disk.
- Optimize your software. Use memory based caching techniques to reduce the request to your drive.
- If you have a software that makes very frequent disk calls but the files are temporary and does not need to be kept over time, try using ramdisk.
- Also, as we are now almost entering 2013, in addition to above, the option of simply awesome IO storage devices are affordable, namely SSDs. SSDs are awesome!!!