banner



What Is Virutal Machine Quality Of Service

Hello folks,

As we are approaching the holidays, and being busy preparing for the new year! I would like to share with you a nifty PowerShell tool to set Hyper-V storage Quality of Service (QoS).

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 or later version, please check the official documentation.

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 is what we call a reactive approach.

To measure a VM, you can use the Measure-VM cmdlet but first, you must enable VMResourceMetering. The virtual machine metrics infrastructure has 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 straightforward, the new Storage QoS feature is available under Advanced Features for each individual virtual hard drive as shown in the figure below:

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.

The answer is PowerShell of course!

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

          <# .SYNOPSIS Set Storage Quality of Service for all Virtual Machines.  .DESCRIPTION Set Minimum and Maximum Storage Quality of Service for all Virtual Machines. .NOTES File Name : Set-VMStorageIO.ps1 Author    : Charbel Nemnom Version   : 1.1 Requires  : PowerShell Version 4.0 or above OS        : Windows Server 2012 R2 Hyper-V or Free Hyper-V Server 2012 R2  .LINK To provide feedback or for further assistance please visit: https://charbelnemnom.com  .PARAMETER HVServerName The name of a single Hyper-V Server .PARAMETER Disable Switch to disable Storage QoS .PARAMETER MinMax The storage QoS to be set - Maximum, Minimum or Both .PARAMETER StorageMinIO The Storage minimum limit IO number to be set .PARAMETER StorageMaxIO The Storage maximum limit IO number to be set  .EXAMPLE .\Set-VMStorageIO -HVServerName <HyperVServerName> -MinMax <Maximum> -StorageMaxIO <500> This example will set the maximum Storage QoS for all virtual machines to 500. .EXAMPLE .\Set-VMStorageIO -HVServerName <HyperVServerName> -MinMax <Minimum> -StorageMinIO <250> This example will set the minimum Storage QoS for all virtual machines to 250. .EXAMPLE .\Set-VMStorageIO -HVServerName <HyperVServerName> -MinMax <Both> -StorageMinIO <250> -StorageMaxIO <1000> This example will set the Storage QoS for minimum 250 IOPS and maximum 1000 IOPS for all virtual machines. .EXAMPLE .\Set-VMStorageIO -HVServerName <HyperVServerName> -Disable This example will disable the Storage QoS for all virtual machines. #>  [CmdletBinding()] param (     [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'Hyper-V Server Name')]     [Alias('Hyper-V Server')]     [String]$HVServerName,          [Parameter(HelpMessage = 'Disable Storage QoS', ParameterSetName = "Disable")]     [Switch]$Disable,          [Parameter(Mandatory = $true, HelpMessage = 'Maximun, Minimum or Both', ParameterSetName = "Enable")]     [ValidateSet("Maximum", "Minimum", "Both")]     [String]$MinMax = "Maximum",          [Parameter(HelpMessage = 'Storage Minimum IO', ParameterSetName = "Enable")]     [Int]$StorageMinIO,          [Parameter(HelpMessage = 'Storage Maximum IO', ParameterSetName = "Enable")]     [Int]$StorageMaxIO )  # If Disable switch equal to true, disable Storage QoS on all VMs If ($Disable) {     $VMIOPs = Get-VM -ComputerName $HVServerName | Get-VMHardDiskDrive     foreach ($VM in $VMIOPs) {         Set-VMHardDiskDrive -ComputerName $HVServerName -VMName $VM.VMName -ControllerType $VM.ControllerType -ControllerNumber $VM.ControllerNumber -ControllerLocation $VM.ControllerLocation -MinimumIOPS $false -MaximumIOPS $false     }    } else {          If ($StorageMinIO -eq '0' -and $StorageMaxIO -eq '0') {         Write-Error "Minimum and Maximum IOPs cannot both be set to Zero!"         Break     }          If ($StorageMinIO -gt $StorageMaxIO) {         Write-Error "The maximum IOPS must be equal to or greater than the minimum IOPS or set to zero to accept the system default value!"         break     }               $VMIOPs = Get-VM -ComputerName $HVServerName | Get-VMHardDiskDrive          If ($MinMax -eq "Maximum") {         foreach ($VM in $VMIOPs) {             Set-VMHardDiskDrive -ComputerName $HVServerName -VMName $VM.VMName -ControllerType $VM.ControllerType -ControllerNumber $VM.ControllerNumber -ControllerLocation $VM.ControllerLocation -MaximumIOPS $StorageMaxIO         }     } elseif ($MinMax -eq "Minimum") {         foreach ($VM in $VMIOPs) {             Set-VMHardDiskDrive -ComputerName $HVServerName -VMName $VM.VMName -ControllerType $VM.ControllerType -ControllerNumber $VM.ControllerNumber -ControllerLocation $VM.ControllerLocation -MinimumIOPS $StorageMinIO         }     } else {         foreach ($VM in $VMIOPs) {             Set-VMHardDiskDrive -ComputerName $HVServerName -VMName $VM.VMName -ControllerType $VM.ControllerType -ControllerNumber $VM.ControllerNumber -ControllerLocation $VM.ControllerLocation -MinimumIOPS $StorageMinIO -MaximumIOPS $StorageMaxIO         }        } } # End        

Here you so go Hyper-V storage QoS Maximum IOPs is set for all virtual machines, I feel it's 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:

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

HV12R2StorageQoS-03

Enjoy the holidays… Party smile

Cheers,
/Charbel

Related Posts

What Is Virutal Machine Quality Of Service

Source: https://charbelnemnom.com/how-to-set-storage-quality-of-service-qos-on-all-virtual-hard-disks-via-powershell-hyperv-powershell/

Posted by: meyerbesperstoont.blogspot.com

0 Response to "What Is Virutal Machine Quality Of Service"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel