Linux server I/O read-write test

Source: Internet
Author: User

How Linux tests IO performance (disk read/write speed)

These days to do the MySQL performance test, a huge company, find a few performance testing machines are very tangled, finally coordinated to two, IO performance is not known.
The database is an IO-intensive application, so evaluate the server's IO performance first to see if it matches the machine on the line.

I've always known that using the DD (device to device) command can simply test the disk's IO read and write speed, but not delve into it.
But this time to do performance testing of the relationship, need to get a relatively accurate value (before the test ate this aspect of the loss, insert a digression, performance testing must first confirm a good test environment. )
The common online method is to use the Hdparm and dd command to test, but the actual use of the problem, and test results always feel biased, the heart is not bottom.
So it is safe to study the next two commands, but also do some testing and analysis, simple summary.

Usage:
1. Test IO Read

Hdparm-t--direct/dev/sda3

Io reads the above command test, but the Hdparm tool needs to be installed on its own and needs to be executed by the root user.

2. Test IO Write
Sync;/usr/bin/time-p bash-c "(dd If=/dev/zero of=test.dd bs=1000k count=20000;sync)"

DD bs=1m count=20000 if=/dev/zero of=test.dd conv=fdatasync DD command test is the sequential write and read mode of IO.

3. View File system block size

Tune2fs-l/dev/sda1 | grep Block

(1) Sync command is used to flush the file system buffer, The actual effect of the Sync command is to write data buffers in memory to disk.
          performs the next sync command first to reduce the impact on subsequent tests. You can also use  echo 3 >/proc/sys/vm/drop_caches  to clear the cache. The
(2) Time command is used to test the execution times of the command, and the shell is built with a temporal command, where we use the full path to specify the non-built command to use. The
        -p option sets the time output format to the POSIX default time format, in seconds, and the output form of time-p can be seen in the subsequent test section. The function of the
(3) Bash command  -c option is to execute the following string argument as a bash script, which may seem superfluous, as if it were straightforward to execute,
        not actually, Because the following string contains two command lines, the time command needs to count the execution times of the two command lines. The
(4) parenthesis means that another child process executes the script in parentheses, and the DD command line does not speak here, but Baidu does not know.
         focus on the sync command, because when DD exits, much of this command-line commit is in the memory buffer (write cache), even if the machine's memory is much larger than the data you submit,
         that might be in memory, and then sync to write the in-memory data to disk, or it would be the test memory write speed, which is obviously not the result you want.


Test Practice:
Some tests were done on a memory 64g,sas hard drive.
During the test, we need to pay attention to two points, disk read and write speed and IO usage, we use the Iopp and Iostat tools to observe respectively.

Test Write Speed:
Test write 20G data, the larger the amount of data, the test value should be more accurate.
# sync;/usr/bin/time-p Bash-c "(dd If=/dev/zero of=test.dd bs=1m count=20000)"
20000+0 Records in
20000+0 Records out
Real 92.87
User 0.00
SYS 18.08

The time to write 20000M is 92.87s, so the write speed of the disk is 215.35mb/sec (20000m/92.87).

Test method:
A. Test disk IO write speed
# time DD If=/dev/zero of=/test.dbf bs=8k count=300000
300000+0 Records in
300000+0 Records out
10.59s Real 0.43s User 9.40s system
# DU-SM/TEST.DBF
2347/test.dbf

Can see, in 10.59 seconds time, generate 2347M of a file, Io write speed about 221.6mb/sec;
Of course, this speed can be tested several times to take an average, in line with probability statistics.


With Iostat observation,%util has been in the state of 100%, while the Iopp display of the DD command write speed is basically the same as the value calculated above (the sampling time is set to 5s)
# iostat-x 5
device:rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await SVCTM%util
SDA 0.00 0.00 0.20 864.00 1.60 449004.80 519.56 143.61 163.46 1.16 100.00

# Iopp-i-K 5
PID Rchar wchar syscr syscw rkb wkb cwkb command
32566 1033216 1033216 0 0 0 1034868 0 DD

Note: The current working directory of the command line is on the partition/dev/sda3, so test.dd This file is also created on this partition, the following read test will be used to this file.

test Read speed:
make a comparison between DD and hdparm:
# hdparm-t--direct/dev/sda3
/dev/sda3:
Timing o_direct disk reads:2108 MB in 3.00 seconds = 702.34 mb/sec

The test result of the hdparm is that the 3s reads 2108MB and the reading speed is 702.34MB.

Because the Hdparm test time is too short, the iostat and Iopp sampling times are adjusted to 1s.

Iostat-x 1
device:rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await SVCTM%util
SDA 0.00 0.00 2752.00 1.00 1409024.00 8.00 511.82 4.64 1.69 0.35 96.10

Iopp-i-K 1
PID Rchar wchar syscr syscw rkb wkb cwkb command
32349 733184 0 0 0 733184 0 0 hdparm

Read Test with DD
# echo 3 >/proc/sys/vm/drop_caches; /USR/BIN/TIME-P DD if=test.dd of=/dev/null bs=1m
20000+0 Records in
20000+0 Records out
Real 35.69
User 0.00
SYS 9.81

Read 20G, reading speed is 560.38mb/sec.

Read will be faster than write, Iostat and Iopp sampling time adjusted to every 3s.
device:rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await SVCTM%util
SDA 106.67 0.00 5851.00 0.33 1434256.00 2.67 245.12 1.62 0.28 0.16 93.60

PID Rchar wchar syscr syscw rkb wkb cwkb command
17004 1449984 1449984 1 1 1450760 0 0 DD

test the speed at which IO reads and writes simultaneously
# time DD if=/dev/sda1 of=test.dbf bs=8k
13048+1 Records in
13048+1 Records out
3.73s Real 0.04s user 2.39s system
# DU-SM TEST.DBF
103 test.dbf

Conclusion:

There is a difference between the read speed and the hdparm of DD test,
The read-write block size test is set through the BS option (the default is 512 bytes, the test uses 1M),
It can be seen that the measured speed of DD is related to the size of the read-write block, and may be affected by the process of Io reading and writing in the system.
Hdparm test principle did not do in-depth research, it may be and DD test methods differ, need to know this.

Overall, the actual test speed of Io is affected by a number of factors, including the way of reading and writing (random or sequential, hdparm and DD tests are sequential read and write), caching mechanism, test sampling and so on.
So it is not likely to get a definite value (same command line multiple tests are not the same, but the difference is smaller), the above method in the read test is recommended to use Hdparm.
Although the above data is biased, the IO performance of the machine can be generally analyzed. Just need to be clear, these test values are in what kind of environment to obtain


This article is from the "Dream to Reality" blog, please be sure to keep this source http://lookingdream.blog.51cto.com/5177800/1898807

Linux server I/O read-write test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.