How to Check Disk Queue Length in Linux

Written by: Bobbin Zachariah   |   Last updated: August 20, 2022

The average disk queue length is the average number of read and write operations that were queued during a selected interval for the chosen device. It's important to watch them as these values provide one of the representations of the storage performance. Higher values indicate that the quantity cannot continue with the requests from the appliance, leading to higher response times.

In this tutorial, we will learn how to check disk queue length using Linux commands.

1. Using iostat command

In Linux/ Unix system, iostat command is mostly used to generate statistics of input/output devices.

The iostat utility tool is part of the sysstat package. If not found, installed sysstat using the following command:

sudo apt install sysstat -y   [On ubuntu]
sudo yum install sysstat -y  [On centos]

To display average disk queue length use iostat with -x option, this will give extended stats. The field aqu-sz indicates the average queue length of the requests that were issued to the device or integral average over the number of IOs in progress. In the old versions, the field would be avgqu-sz.

iostat -x
Disk average queue length using iostat

2. Using sar command

Sar command is used to monitor the performance of Linux systems which includes CPU, Memory, and I/O in real-time. Sar is part of the sysstat packge.

Sar command with -d option displays activity for each block device. To print, the statistics with the actual device name add another -p option.

The field aqu-sz helps to find average queue length. The field is same for iostat command.

sar -p -d 1 1 
check disk queue length using sar command

3. From /proc/diskstats

The /proc/diskstats file displays the I/O statistics of block devices. The result returned by this command is always the raw value.

From kernel version 5.5+, /proc/diskstats contains a total of 20 fields.

#14 - weighted time spent doing I/Os (ms)

The average disk queue length can be calculated by checking data changes in the 14th field in a period of time.

To display the content of the /proc/diskstats and filter by specific disk, type:

cat /proc/diskstats | grep 'sda'

Output:

8       0 sda 15728 6935 1377412 10839 28870 15373 995570 49457 0 36360 60296 0 0 0 0 0 0

Conclusion

In this tutorial, we learned about different command-line utility tools to check disk queue length in the Linux system.

About The Author

Bobbin Zachariah

Bobbin Zachariah

Bobbin Zachariah is an experienced Linux engineer who has been supporting infrastructure for many companies. He specializes in Shell scripting, AWS Cloud, JavaScript, and Nodejs. He has qualified Master’s degree in computer science. He holds Red Hat Certified Engineer (RHCE) certification and RedHat Enable Sysadmin.

SHARE

Comments

Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment