Learning how to check disk queue length on Linux can help deal with a number of situations pretty seamlessly. The major benefit, though, is that you can monitor and enhance your storage performance.
The standard disk queue length for selected devices is the average number of write and read operations queued during the picked interval. It is necessary to look upon them because it has a proper impact on your storage performance. The main thing to keep in mind, for now, is that the number of units in the disk queue, the more disk operations have been waiting.
Next in our list is what should be the good queue length with respect to Linux, and maybe you will be wondering about the good queue length in Linux. So here is the answer you should know that a good queue length should be half or must be less than a quarter of the actual size of queue length. As an example, if you have a 20 disk raid size, then the queue length should be 10 or less.
What Should be a Normal Disk Queue Length?
Before dealing with commands, it is crucial we look at some commonly helpful things related to them. With that being said, let’s understand the scenes around standard queue length.
Speaking of queue length, 10-20ms is recorded as standard. However, if your numbers exceed 10-20ms or go over 40-60ms, you should know it is not promising.
Can I Change the Disk Queue Length?
No, I know the answer looks pretty straightforward to you, but still, you can’t change the disk queue length that seamlessly. As disk performance relies on the disk queue length, you cannot bring necessary modifications. Yes, the one thing you are free to do here is an upgrade.
As we know, the things related to disk queue length are crucial but do not worry; we have covered it for you in the guide. So let’s proceed further and look at how we can validate the disk queue length in your Linux-based operating system.
The iostat Command
If we talk about the
iostat command, it is only used in terms of input statistics and the concerned output devices. The
iostat utility is a segment of the
sysstat package. It is possible that it will not exist in your system but do not worry; getting the same installed is an easy task.
If you are using the Ubuntu OS, then simply invoke the following command:
$ sudo apt install sysstat -y
If you are using the CentOS then you should run the following command:
$ sudo yum install sysstat -y
Using the iostat Command
So let’s move forward and use the
iostat command. Let’s use option -x right along with the
iostat command. This option is used to extend statistics.
$ iostat -x
As you can see in the attached screenshot, the keyword
aqu-sz narrates the issued requests of the device lie in the average queue length, but be aware this might also indicate the number of input or output devices in progress. If you are running an older version, you may find the
avgqu-sz option instead.
The sar Command
In Linux “
sar” command is used to observe the Linux system resources like Disk usage, Memory consumption, Input or Output devices consumption, and many more. It seamlessly provides real-time data for all these resources and is undoubtedly among the very best benefit of sar command.
So the syntax of
sar command is like this:
$ sar [option]
You can place multiple options too with the sar command. Using the multiple options with the sar command is going to save our time. Now to view the disk queue length, we are going to print the statistics and activity of each block in our device.
To have a visual experience of the activity of each block of our device, we will need to employ the
-d option with the sar command. However, for printing the statistics, use the
-p option next to
-d. This will help you monitor the activity of each block.
Note: If you want to print the statistics with the device name, place the
-p option next to
aqu-sz field will help us in finding the average queue length. So follow the following command to get started with sar commands.
$ sar -p -d 1 1
Maybe you never heard about the
/proc/diskstats commands, and it is totally fine because this one command is used to display the
I/O statistics of banned or blocked devices. You will always see a raw value in return for this command.
As there are versions of kernels and from kernel version 5.5 or above, the
/proc/diskstats contains almost twenty fields.
As I have told you that there are twenty fields, but the one from which we have concern is field number fourteen. Field fourteen contains the doings and time spent in ms of
To calculate the average disk queue length, you just have to check the changes in the field fourteen in mean times.
You can run the
/proc/diskstats command in the following format:
$ cat /proc/diskstats | grep ‘sda2’
In my case, we’re using this command for sda2, but in your case, it could be sda or sda1, so filter your drive according to your need.
In this guide, we discussed the three main commands on how to check the disk queue length on Linux. We have explored these commands further, along with screenshots about checking disk queue length on Linux.
If this guide helped you, please share it.