PowerShell

PowerShell is King – Measure disk performance for IOPS and Transfer rate

The need

Since I build datacenters I need to verify performance and you can do that using SQLIO. But there is a lot of parameters, a lot of typing and to make testing a bit more consistent I was reading Jose Barreto’s blog http://blogs.technet.com/b/josebda/archive/2013/03/28/sqlio-powershell-and-storage-performance-measuring-iops-throughput-and-latency-for-both-local-disks-and-smb-file-shares.aspx and that gave me inspiration to create a PowerShell script that is a bit more complete and here you can see the result of it. We use this to measure performance on local disks, SMB storage, Storage Spaces, SAN storage, iSCSI storage, basically everything, now it is easy to “spot” the issue, since we have seen the numbers so many times.

Measure-DiskPerformance - pic01

Output sample in table format.

Measure-DiskPerformance - pic02

Output in Grid view.

The Download

You can download the script from here: http://1drv.ms/1pQNr4i

To use it you need to have SQLIO from Microsoft and you need to store the SQLIO.exe file in the same folder as the script, this way it is easy to move around the test tool as a kit, since SQLIO does not really needs to be installed, the download is an MSI file, so you need to install it once or extract it

You can download SQLIO from here: http://www.microsoft.com/en-us/download/details.aspx?id=20163

The script it is rather easy, it is basically a wrapper for SQLIO.exe but it gives you an output as a table or in a grid. There is two options to measure workload, you either measure IOPS or Transfer rate.

The howto

.\Measure-DiskPerformance.ps1 -TestFileName test.dat –TestFileSizeInGB 1 -TestFilepath C:\VMs -TestMode Get-LargeIO -FastMode True -RemoveTestFile True -OutputFormat Out-GridView

Explanation:

-TestFileName test.dat

The name of the file, it will create the file using FSUTIL, but it checks if it exists and if it does it stops, you can override that with the –RemoveTestFile True

–TestFileSizeInGB 1

Size of the file, it has fixed values, use the TAB key to flip through them

-TestFilepath C:\VMs

The folder, can also be an UNC path, it will create the folder so it does not need to exist.

-TestMode Get-LargeIO

There is too test modes Get-LargeIO or Get-SmallIO, you use Get-LargeIO to measure the transfer rate and you use Get-SmallIO to measure IOPS

-FastMode True

Fastmode true runs each test for just 10 seconds, it gives you a hint, if you don’t set it or set it to false it will run for 60 sec (it will take a break for 10 sec between each run)

-RemoveTestFile True

Removes the test file if it exists

-OutputFormat Out-GridView

Choose between Out-Gridview or Format-Table

/mike

Categories: PowerShell, Windows Server 2012 R2

Tagged as:

37 replies »

  1. Arwidmark writes the following on his blog. Comment? “And please do not create the file using FSUtil, because it will just create an empty file, which the controller cache may suck into RAM immediately and your test results will be off the charts. Create a “real” file, with content, generate a giant ISO file, or a large WinRAR archive, anything you can think of as long as the file is full with data.”

    • Yep, I know, we disagree on that. I have come to the conclusion that it does not matter much as long as you use the same method everytime. But when using FSUTIL you must run it twice, the first time to create the file and the second to fill it with data, if you run it only once it will 100% empty

  2. Could this script be used to measure disk performance inside a Virtual Machine ?
    Or is just for Hyper-V hosts ?
    Tips for measure diskspeed inside a VM?
    /Anders

      • Ok, great! What is “normal” values for different types of disksetups (SSD, SAS-Mirror, SATA-III ? would be great with som kind of list. I Ran the script within a VM where the vhdx is on SATA-3 mirror (storage spaces in 2012 R2) and got 7000MB and 13000 IOPs. That could not be correct I think? Runing on the host towards the same storage got me around 90MB and 200 IOPs. And towards a SSD-storage got me 535 MB/Sec and 1050 IOPs on the same host.

      • That cpould be correct, since the the fabric layer will try to not do anything pointless, it vill use cache and similar functions to avoid unneeded actions. But we have another script that will better simulate real load. (will post as soon as I have 5 minutes to spare)

      • Hi Mike!
        Have you found 5 minutes to spare, so that you could upload that other script for better testing disk performance inside a VM?
        /Anders

  3. Would be great to see that other script once you have uploaded it. I also have a requirement for testing against different types of storage.

  4. I’m having this issue while running the script,

    Method invocation failed because [System.Object[]] doesn’t contain a method named ‘Split’.
    At C:\PS\Measure-DiskPerformance.ps1:120 char:25
    + $mbs = $Result.Split <<<< ("`n")[11].Split(':')[1].Trim()
    + CategoryInfo : InvalidOperation: (Split:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

    any advice on to resolve the error?

    • I ran into the same problem while doing some testing of my own. I think that it was a powershell version issue and that the resolution was to remove the first split (.Split(“`n”)), it seems that the output already was delivered by line.

      • As I wanted to test the performance of an old 2003 Server I hacked the script so that it now runs on PowerShell Version 2 with Format-Table

  5. I am seeing this error in PS and the throughput and IOPS do not populate
    Method invocation failed because [System.Object[]] doesn’t contain a method named ‘Split’.

  6. What if i want to run this for a long period of time ? Say 3 days and get results summing up the iops need ?

  7. SQLIO no longer available, has been replaced by DiskSpd: https://gallery.technet.microsoft.com/DiskSpd-a-robust-storage-6cd2f223

    The original download link for SQLIO now points at a PDF which states:

    “The SQLIO Disk Subsystem Benchmark Tool has been retired and replaced by
    DiskSpd.exe. You can download the tool and documentation
    from http://aka.ms/diskspd. DiskSpd.exe is a versatile storage load generator and
    performance tool from Microsoft that can be used to run storage performance
    tests against files, partitions, and physical disks. It can simulate SQL Server I/O
    activity or more complex, variable access patterns.
    DISKSPD is provided “as is,” and no support is offered for any problems
    encountered when using the tool. Please see the EULA.doc for the DiskSpd
    license agreement.”

  8. The SQLIO download has been pulled by Microsoft and replaced with a Readme.PDF which says ‘The SQLIO Disk Subsystem Benchmark Tool has been retired and replaced by DiskSpd.exe.’ Bummer.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.