In this recipe, we will be discussing how to benchmark the disk IOPS using open source tools.
As mentioned previously, a disk can be read in either sequential or random orders. To measure the disk accurately, we need to perform more random read/write operations, which gives more stress to the disk. To calculate the IOPS (Input/Output Per Second) of a disk, we can either use fio or bonnie++ tools, which do sequential/random operations over the disk. In this chapter, let's use the fio (Flexible I/O) tool to calculate the IOPS for the disk.
Let's download the latest version of the fio
module from http://brick.kernel.dk/snaps/, also download libaio-devel
, which would be the ioengine
we will be using for the IOPS. This ioengine
defines, how the fio
module needs to submit the I/O requests to the kernel. There are multiple ioengines you can specify for the I/O requests such as sync
, mmap
, and so on. You can refer to the main page of fio for all the supported ioengines. After downloading the fio module, let's follow the regular Linux source installation method as configure
, make
, and make install
.
Sequential mixed read and write
Let's run a sample sequential mixed read/write, as shown here:
$ ./fio --ioengine=libaio --direct=1 --name=test_seq_mix_rw --filename=test_seq --bs=8k --iodepth=32 --size=1G --readwrite=rw --rwmixread=50
test_seq_mix_rw: (g=0): rw=rw, bs=8K-8K/8K-8K/8K-8K, ioengine=libaio, iodepth=32
...
...
test_seq_mix_rw: (groupid=0, jobs=1): err= 0: pid=43596: Fri Dec 30 23:31:11 2016
read : io=525088KB, bw=1948.1KB/s, iops=243 , runt=269430msec
...
bw (KB/s) : min= 15, max= 6183, per=100.00%, avg=2002.59, stdev=1253.68
write: io=523488KB, bw=1942.1KB/s, iops=242 , runt=269430msec
...
bw (KB/s) : min= 192, max= 5888, per=100.00%, avg=2001.74, stdev=1246.19
...
Run status group 0 (all jobs):
READ: io=525088KB, aggrb=1948KB/s, minb=1948KB/s, maxb=1948KB/s, mint=269430msec, maxt=269430msec
WRITE: io=523488KB, aggrb=1942KB/s, minb=1942KB/s, maxb=1942KB/s, mint=269430msec, maxt=269430msec
Disk stats (read/write):
sda: ios=65608/65423, merge=0/5, ticks=869519/853644, in_queue=1723445, util=99.85%
Random mixed read and write
Let's run a sample random mixed read/write, as shown here:
$ ./fio --ioengine=libaio --direct=1 --name=test_rand_mix_rw --filename=test_rand --bs=8k --iodepth=32 --size=1G --readwrite=randrw --rwmixread=50
test_rand_mix_rw: (g=0): rw=randrw, bs=8K-8K/8K-8K/8K-8K, ioengine=libaio, iodepth=32
...
...
test_rand_mix_rw: (groupid=0, jobs=1): err= 0: pid=43893: Fri Dec 30 23:49:19 2016
read : io=525088KB, bw=1018.9KB/s, iops=127 , runt=515375msec
...
bw (KB/s) : min= 8, max= 6720, per=100.00%, avg=1124.47, stdev=964.38
write: io=523488KB, bw=1015.8KB/s, iops=126 , runt=515375msec
...
bw (KB/s) : min= 8, max= 6904, per=100.00%, avg=1125.46, stdev=975.04
...
Run status group 0 (all jobs):
READ: io=525088KB, aggrb=1018KB/s, minb=1018KB/s, maxb=1018KB/s, mint=515375msec, maxt=515375msec
WRITE: io=523488KB, aggrb=1015KB/s, minb=1015KB/s, maxb=1015KB/s, mint=515375msec, maxt=515375msec
Disk stats (read/write):
sda: ios=65609/65456, merge=0/4, ticks=7382037/5520238, in_queue=12902772, util=100.00%
We ran the preceding test cases to work on 1 GB (--size
) file without any cache (--direct
), by doing 32 concurrent I/O requests (--iodepth
), with a block size of 8 KB (--bs
) as 50% read and 50% write operations (--rwmixread
). From the preceding sequential test results, the bw
(bandwidth), IOPS values are pretty high when compared with random test results. That is, in sequential test cases, we gain approximately 50% more IOPS (read=243
, read=242
) than with the random IOPS (read=127
, write=126
).
Fio also provides more information such, as I/O submission latency and complete latency, along with CPU usage on the conducted test cases. I would encourage you to read more useful information about fio's features from its man pages.