Pages

Wednesday, May 9, 2012

Meassure disk performance

This tutorial was tested on Slackware Linux only but should work for any other Unix with some minor changes in the iostat options. Keep in mind that some file systems (zfs, vxfs etc.) have their own tools to measure disk performance. In this case you should refer to them.
To meassure the disk performance of a specific disk use iostat - not dd. You can use dd to create some load but not to meassure the performance of a disk. The usage of iostat is very easy, a simple example for /dev/sdb could look like this: 

# iostat -dm -p /dev/sdb 1 100
Linux 2.6.33.4 (dc01)        05/07/2012      _x86_64_        (2 CPU)

Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sdb               0.35         0.01         0.05       3280      12289
sdb1              0.34         0.01         0.05       3280      12289

Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sdb               0.00         0.00         0.00          0          0
sdb1              0.00         0.00         0.00          0          0
...

The options I used in this example are the following:

-d:  use devices only (not CPU)
-m:  show results in megabytes
-p:  the device you want to monitor
1:   interval
100: count

You can display multiple devices by comma seperating them:

# iostat -dm -p /dev/sda,/dev/sdb 1 100
...

Each device you want to monitor will be displayed as  a device with an overall statistic for all partitions. Partitions will be listed separately (see above). The first output is always the cumulative results since the machine was booted: 

Linux 2.6.33.4 (dc01)        05/07/2012      _x86_64_        (2 CPU)

Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
md0               1.94         0.01         0.01      22956      16375

In this case the device md0 has read 22.42GB and written 15.99GB since the machine was booted.
To meassure the speed of your hard disk you can use dd to create some load and iostat to measure the read and write speed. Open two consoles, on the first start iostat first:

# iostat -dm -p /dev/sdb 1 100
...

On the second start dd to create a 100MB file (/dev/sdb1 was mounted on /export):

# dd if=/dev/urandom of=/export/foo bs=1024 count=102400
102400+0 records in
102400+0 records out
104857600 bytes (105 MB) copied, 14.0477 s, 7.5 MB/s

After a while you should see in the iostat console an output like this:

...
Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sdb              84.00         0.00        35.55          0         35
sdb1             84.00         0.00        35.55          0         35

Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sdb              88.00         0.00        43.93          0         43
sdb1             88.00         0.00        43.93          0         43

Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sdb              42.42         0.00        20.73          0         20
sdb1             42.42         0.00        20.73          0         20
...

If you count all result under MB_wrtn/s then you will get about 100MB. Instead of the 14 seconds that dd indicates for the writing of 100MB, the real time that was needed is 3 seconds.

No comments:

Post a Comment