2 ways to check disk IOPS in Linux
2 ways to check disk IOPS in Linux
Iostat command would not stop by default if we don’t specify the count. You can
simply press the CTRL + C key combination. This will interrupt the execution of the
command and return control back to the terminal prompt.
Let’s see some examples how to use iostat command.
To display disk I/O statistics every 2 seconds for 5 times, the following command can
be used:
iostat -xd 2 5
The “-d” option tells iostat to display information about the disk, and the “-x” option
tells iostat to display extended statistics.
If I need to check the IOPS for a specific device, such as /dev/sda, I will run the
command like this. Here the interval is 3s.
iostat -xd 3 /dev/sda
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 0.00 100 50 50 100 10 3.00 0.00 0.00 5.00
The IOPS for this device xvda is r/s + w/s = 100 + 50 =150
This output can be a bit confusing, so let’s break it down.
The “rrqm/s” column shows the number of read requests that were merged
per second. The “wrqm/s” column shows the number of write requests that
were merged per second.
The “r/s” column shows the number of reads per second, and the “w/s”
column shows the number of writes per second.
The “rkB/s” column shows the number of kilobytes read per second, and the
“wkB/s” column shows the number of kilobytes written per second.
The “avgrq-sz” column shows the average size of each request in sectors.
The “avgqu-sz” column shows the average queue length of the requests. The
“await” column shows the average time (in milliseconds) that each request
spent in the queue.
The “svctm” column shows the average service time (in milliseconds) for
each request. And finally, the “%util” column shows the percentage of time
that the disk was active.
09:20:01 AM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
09:30:01 AM dev253-0 2.32 0.00 19.90 8.56 0.01 3.32 0.11 0.03
09:30:01 AM dev253-16 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
09:40:01 AM dev253-0 3.13 0.00 28.63 9.15 0.00 1.47 0.06 0.02
09:40:01 AM dev253-16 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
09:50:01 AM dev253-0 3.05 0.00 25.88 8.47 0.01 2.31 0.09 0.03
How to fix disk IO issue in Linux
Here are a few tips to check disk issue:
Make sure that your disks are in good condition. If they are damaged or worn
out, they will not perform as well.
Make sure that your disks are properly configured. If they are not configured
correctly, they will not be able to handle the load.
If you are having problems with disk io, you can try using
a tool like iotop to help identify the problem.
iotop is a Linux tool that allows you to see what
processes are using the most I/O. This can be
helpful in identifying which process is causing the
problem.
You can install iotop using the following command: sudo
apt-get install iotop.
Once it is installed, you can use the following command
to see which processes are using the most I/O: iotop.