How to properly use 'dd' to benchmark the write speed of your disk?

Source: Internet
Author: User
Tags vps

This article is written to address sometimes incorrect usage of the "dd" program to measure disk write performance on a VPs by some visitors of the lowendbox.com website, and is originally based on this question and my answer to it.

Initially published on 2010-11-29.

Q: What is the difference between the following?
    1. Dd BS = 1 m COUNT = 128 If =/dev/Zero of = test
    2. Dd BS = 1 m COUNT = 128 If =/dev/Zero of = test; sync
    3. Dd BS = 1 m COUNT = 128 If =/dev/Zero of = test Conv = fdatasync
    4. Dd BS = 1 m COUNT = 128 If =/dev/Zero of = test Oflag = dsync
A: The difference is in handling of the write cache in Ram:
  1. dd BS = 1 mb count = 128 If =/dev/Zero of = test
    the default behaviour of DD is to not" sync "(I. e. not ask the OS to completely write the data to disk before DD exiting ). the above command will just commit your 128 MB of data into a RAM buffer (write cache)-this will be really fast and it will show you the hugely inflated benchmark result right away. however, the server in the background is still busy, continuing to write out data from the RAM cache to disk.
  2. dd BS = 1 m COUNT = 128 If =/dev/Zero of = test; sync
    absolutely identical to the previous case, as anyone who understands how * nix shell works shocould surely know that adding a ; sync does not affect the operation of previous command in any way, because it is executed independently, after the first command completes. so your (wrong) MB/sec value is already printed on screen while that sync is only preparing to be executed.
  3. dd BS = 1 m COUNT = 128 If =/dev/Zero of = test Conv = fdatasync
    This tells DD to require a complete" sync "once, right before it exits. so it commits the whole 128 MB of data, then tells the operating system: "OK, now ensure this is completely on disk ", only then measures the total time it took to do all that and calculates the benchmark result.
  4. Dd BS = 1 m COUNT = 128 If =/dev/Zero of = test Oflag = dsync 
    HereDdWill ask for completely synchronous output to disk, I. e. ensure that its write requests don't even return until the submitted data is on disk. in the above example, this will mean sync 'ing once per megabyte, or 128 times in total. it wowould probably be the slowest mode, as the write cache is basically unused at all in this case.
Which one do you suggest?
    • Dd BS = 1 m COUNT = 128 If =/dev/Zero of = test Conv = fdatasync

This behaviour is perhaps the closest to the way real-world tasks behave. If your server or VPs is really fast and the above test completes in a second or less, try increasingCount =Number to 1024 or so, to get a more accurate averaged result.

 

Original article: http://romanrm.ru/en/dd-benchmark

 

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.