How to Set Hyper-V Storage Quality of Service (QoS) on All Virtual Hard Disks via PowerShell? #HyperV #PowerShell

Hello folks,

As we are approaching the holidays, and being busy preparing for the new year! I would like to share a script with you.

Hyper-V Storage QoS!

Killer feature… Microsoft introduced in Windows Server 2012 R2, Hyper-V storage Quality of Service (QoS). Storage QoS enables you to manage storage throughput for virtual hard disks that are accessed by your virtual machines.

Storage QoS enables you to specify the maximum and minimum I/O loads in terms of I/O operations per second (IOPS) for each virtual disk in your virtual machines. Minimum and maximum IOPS are measured in 8 KB increments

Now If you are concerned about a specific virtual hard disk for a particular VM is not receiving sufficient disk I/O, then you can set a minimum IOPS level. Remember that minimum is a soft reserve (best effort) which means it might fail but an event will be logged that things are going wrong. On the other hand, if the virtual hard disk is accommodating a very high I/O then you may want to populate the Maximum IOPS field as a way of limiting the total number of IOPS that the virtual hard disk can consume, and ensure that the storage throughput of one virtual hard disk does not impact the performance of another virtual hard disk on the same Hyper-V host.

For more information on what’s new in Storage QoS in Windows Server 2012 R2, click here.

Best Practices: Hyper-V Storage QoS!

If you identify a VM that is using more resources than you want it to use, then you can go ahead and apply a limit to it right away, this what we call a reactive approach.

To measure a VM, you can use Measure-VM cmdlet but first you must enable VMResourceMetering. The virtual machine metrics infrastructure have been extended with storage related attributes in Windows Server 2012 R2, so you can monitor the performance. To do this Microsoft use what they call “normalized IOPs” where every 8K of data is counted as an I/O.

HV12R2StorageQoS-01

The reactive approach is not really ideal, because you are reacting since you have a problem.

What I recommend doing is to take a proactive approach earlier.

So as you are deploying your virtual machines, you can start applying a default limit to all individual VM’s VHDs and then you can raise based on workload demand.

As best practices, consider tiers based on planned usage as Virtual Machines are deployed as the following:

  • VDI VMs: Max 100 IOPs limit
  • General VMs: Max 500 IOPs limit
  • High Performance VMs: > 500 IOPs limit

How can you limit individual VM’s VHD?

The answer is straight forward, the new Storage QoS feature is available under Advanced Features for each individual virtual hard drive as shown in below figure:

HV12R2StorageQoS-02

Automation: Hyper-V Storage QoS!

Now the challenging question is what if you have hundreds of VMs already deployed and you need to start using the proactive approach?

The answer is simple, open each VM settings and limit the maximum IOPs to 500.

And what if each VM has 4 virtual hard disks attached to it? so 400 VHDs Crying face

The answer is PowerShell of course Winking smile

I created the following tool script that will help you to limit all individual VM’s VHDs to a default IO number you specify.

HV12R2StorageQoS-04

Here you so go Hyper-V storage QoS Maximum IOPs is set for all virtual machines Smile, I feel it’s a much easier than having to set the limit individually for each VM’s VHD.

HV12R2StorageQoS-05

If you have more scenarios, please feel free to leave a comment below:

Demo: Hyper-V Storage QoS!

Would you like to see Hyper-V Storage QoS in action? Then make sure to watch this short demo:

Hyper-V Storage QoS In Action!

And now It’s time to sign-off and prepare for the holidays… Airplane 

HV12R2StorageQoS-03

Until then… See you in 2015!

Enjoy the holidays… Party smile

Cheers,
/Charbel

About Charbel Nemnom 323 Articles

Charbel Nemnom is a Microsoft Cloud Consultant and Technical Evangelist, totally fan of the latest’s IT platform solutions, accomplished hands-on technical professional with over 15 years of broad IT Infrastructure experience serving on and guiding technical teams to optimize performance of mission-critical enterprise systems. Excellent communicator adept at identifying business needs and bridging the gap between functional groups and technology to foster targeted and innovative IT project development. Well respected by peers through demonstrating passion for technology and performance improvement. Extensive practical knowledge of complex systems builds, network design and virtualization.

Be the first to comment

Leave a Reply