One of the main bottlenecks in server slowness is the Disk IO. If the speed of your disks are slow, then the CPUs of your servers may be wasting their CPU cycles waiting for IO operation to be completed. You may have enough CPU and memory, but if the Disk IO operation is slow, still you will be encountering slowness while accessing your application or sites as it is the main bottleneck here.
You can get an idea about how long a Read and Write IO operation takes by running following simple commands.
Using DD Command:
- Testing write operation:
time dd if=/dev/zero of=[INPUTFILE] bs=[BLOCK_SIZE]k count=[NUMBER_OF_BLOCKS] && sync" Eg: time dd if=/dev/zero of=testfile bs=512 count=10000000 && sync time dd if=/dev/zero of=testfile bs=512 count=10000000 && sync 10000000+0 records in 10000000+0 records out 5120000000 bytes transferred in 46.046762 secs (111191315 bytes/sec)
Here it is calculating the time to create a 5Gb file assuming block size to be 512Kb.As you can see, it took 46.04 seconds for Write IO operation to get completed for this test.
- Testing read operation:
Prior testing read operation, we would like to make sure that the file it is going to read is not already in memory. So, to evict the item from the memory, you can create a big file (almost size of your memory) with the step as mentioned in write-test operation. Then to test Read IO, you can run following commands:
time dd if=[INPUTFILE] bs=[BLOCK_SIZE] count=[NUMBER_OF_BLOCKS] of=/dev/null time dd if=testfile bs=512 count=10000000 of=/dev/null 10000000+0 records in 10000000+0 records out 5120000000 bytes transferred in 18.435533 secs (277724544 bytes/sec)
As you can see, it took 18.43 seconds for Read IO operation to get completed for this test.
You can run above commands multiple times and take the average.
Using Bonnie ++
Also there is a very good tool to test IO performance. It is called Bonnie++. You can download it from http://sourceforge.net/projects/bonnie/. To install, simply download the file and execute following commands.
tar -zxvf bonnie++-xxx.tgz
./configure && make && make install
To run IO test, simply run the following command:
bonnie++ -d /home/joshi/ -u joshi -s 17000 Using uid:10001, gid:10001. Writing with putc()...done Writing intelligently...done Rewriting...done Reading with getc()...done Reading intelligently...done start 'em...done...done...done... Create files in sequential order...done. Stat files in sequential order...done. Delete files in sequential order...done. Create files in random order...done. Stat files in random order...done. Delete files in random order...done. Version 1.03e ------Sequential Output------ --Sequential Input- --Random- -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP joshi.webair.com 17000M 112951 97 200327 64 30354 9 105744 80 152397 19 627.1 3 ------Sequential Create------ --------Random Create-------- -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP 16 18504 28 +++++ +++ +++++ +++ 16983 25 +++++ +++ +++++ +++joshi.webair.com,17000M,112951,97,200327,64,30354,9,105744,80,152397,19,627.1,3,16,18504,28,+++++,+++,+++++,+++,16983,25,+++++,+++,+++++,+++
Here -d specifies the scratch-dir to write files, -u specified the user to be run as, -s specifies the size in Mb.
You can also specify -x option to mention the number of iterations that you should run.
Also, it is very important to ensure that no other application is doing IO on your server when you run these tests. Else you won’t be getting an accurate measure of your disk IO performance.