Ubuntu学习笔记之test-disk-IO-performance
Linux and Unix Test Disk I/O Performance With dd Command
How can I use dd command on a Linux to test I/O performance of my hard disk drive? How do I check the performance of a hard drive including the read and write speed on a Linux operating systems?
You can use the following commands on a Linux or Unix-like systems for simple I/O performance test:
1 | dd command : It is used to monitor the writing performance of a disk device on a Linux and Unix-like system. [donotprint][/donotprint] |
Use dd command to monitor the reading and writing performance of a disk device:
1 |
|
#Understanding dd command options
In this example, I’m using RAID-10 (Adaptec 5405Z with SAS SSD) array running on a Ubuntu Linux 14.04 LTS server. The basic syntax is as follows to find out server throughput:
1 | dd if=/dev/input.file of=/path/to/output.file bs=block-size count=number-of-blocks oflag=dsync |
Please note that one gigabyte was written for the test and 135 MB/s was server throughput for this test. Where,
1 | if=/dev/zero (if=/dev/input.file) : The name of the input file you want dd the read from. |
Finding server latency time
In this example, 512 bytes were written one thousand times to get RAID10 server latency time:
1 | dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync |
Please note that server throughput and latency time depends upon server/application load too. So I recommend that you run these tests on a newly rebooted server as well as peak time to get better idea about your workload. You can now compare these numbers with all your devices.
But why the server throughput and latency time are so low?
Low values does not mean you are using slow hardware. The value can be low because of the HARDWARE RAID10 controller’s cache.
Use hdparm command to see buffered and cached disk read speed
I suggest you run the following commands 2 or 3 times Perform timings of device reads for benchmark and comparison purposes:
1 | ### Buffered disk read test for /dev/sda ## |
To perform timings of cache reads for benchmark and comparison purposes again run the following command 2-3 times (note the -T option):
1 | ## Cache read benchmark for /dev/sda ### |
OR combine both tests:
1 | hdparm -Tt /dev/sda |
Again note that due to filesystems caching on file operations, you will always see high read rates.
Use dd command on Linux to test read speed
To get accurate read test data, first discard caches before testing by running the following commands:
1 | flush |
Linux Laptop example
Run the following command:
1 |
|
Apple OS X Unix (Macbook pro) example
GNU dd has many more options but OS X/BSD and Unix-like dd command need to run as follows to test real disk I/O and not memory add sync option as follows:
1 | ## Run command 2-3 times to get good results ### |
Not a fan of command line…?
You can use disk utility (gnome-disk-utility) on a Linux or Unix based system to get the same information. The following screenshot is taken from my Fedora Linux v22 VM.
Which method and command do you recommend to use?
1 | I recommend dd command on all Unix-like systems (time sh -c "dd if=/dev/zero of=/tmp/testfile bs=100k count=1k && sync" |
See also: HowTo: Linux Check IDE / SATA Hard Disk Transfer Speed and man pages: hdparm(1)
https://www.cyberciti.biz/tips/how-fast-is-linux-sata-hard-disk.html
https://icesquare.com/wordpress/how-to-improve-zfs-performance/
https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/performance/file_sys_perf.html