howtouselinux

What is IOwait on Linux

Table of Contents

Linux IOwait is a common Linux performance issue. Today we will look at what iowait means and what contributes to this problem. Hope this can give you more ideas about high IOwait issue.

IOwait on Linux

The iowait column on top command output shows the percentage of time that the processor was waiting for I/O to complete. It indicates that the system is waiting on disk or network IO. Because the system is waiting on those resources, it can not fully utilize the CPU.

The process will get “stuck” in D state because of disk io or NFS io. Processes accessing hard NFS mounts will also be put into D state while they wait for the I/O to return – thus a hard NFS mount from a machine that has dropped off of the network can cause processes to go into D state.

High IOWait usually means that your disk subsystem or network storage is overworked.This can occur due to hardware problems (the kernel is waiting for something from a device that never comes) or from kernel-related issues (driver bugs that cause a system call to never return).

High iowaits on specific CPU cores

The io workload on the CPU cores are not evenly distributed. This is a expected behavior of a Linux kernel. When any cpu deals with any task and that task needs to do a IO transaction then cpu issues a request to a IO controller and now it is IO controllers responsibility to serve this request, so as much time the IO controller will take to accomplish the request that much of time that task will be in ‘D’ state and cpu will be just waiting for IO (called as IO_WAIT).

And if system has number of processors then the cpu which is serving to that particular task will wait for IO and will be idle for that amount of time, the other processors will be assigned to other running tasks, so seeing a IOWAIT for particular CPU’s is expected behavior of a Linux kernel.

We can use iotop check which process is generating workloads to our disks. More info about iotop here.

Understanding CPU usage in Linux

Cpu usage in Linux can be a little confusing, especially if you are not familiar with it. Here is a basic rundown of what the different cpu usage percentages mean:

  • 0-4% – The kernel is idle and not doing anything.
  • 5-10% – The kernel is starting to do some work, but is not under any heavy load.
  • 11-20% – The kernel is doing a lot of work and is starting to get bogged down. This is where you might start to see some performance issues.
  • 21-100% – The kernel is under a heavy load and is having difficulty keeping up with all the requests. This is where you will see the biggest performance issues.

 

If you are trying to figure out why your system is slow, checking the cpu usage is a good place to start. If you see that the kernel is under a heavy load, then that is most likely the cause of the problem. Try to find out what is causing the high load and address that issue.

3 ways to check disk performance in Linux

Disk performance can be a tricky thing to optimize, especially on Linux systems. In this blog post, we will discuss three different ways to check disk performance in Linux. This is a handy trick to know if you are experiencing slowdowns or if you want to optimize your disk performance. We will be using the “iostat” command, the “iotop” command, and the “dd” command to check our disk performance.

The iostat command is a great way to see your current disk utilization. You can use the following syntax to run iostat: iostat -x /dev/sda

This will print out a report of your disk activity, including the amount of read and write operations, the average response time etc.

The iotop command is another great way to see what processes are using the most disk I/O. You can use the following syntax to run iotop: iotop -aoP

This will print out a report of the processes that are using the most disk I/O, along with the percentage of disk I/O each process is using. You can then use this information to determine which processes are causing slowdowns.

The dd command is a great way to check the read and write speed of your disk. You can use the following syntax to run dd: dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync

This will create a file called “test” that is 64KB in size and will write zeros to it. This is a good way to test the write speed of your disk. To test the read speed, you can use the following syntax: dd if=test of=/dev/null bs=64k count=16k

 

Related Post:

David Cao
David Cao

Hey there! I am David, a Cloud & DevOps Enthusiast and 18 years of experience as a Linux engineer. I work with AWS, Git & GitHub, Linux, Python, Ansible, and Bash. I am a technical blogger and a Software Engineer, enjoy sharing my learning and contributing to open-source.