Restrict Bandwidth for a Virtual Machine
Learn how to restrict the amount of network bandwidth a virtual machine can use.
January 30, 2013
Q: How do I restrict the amount of network bandwidth a virtual machine can consume?
A: Windows Server 2012 Hyper-V introduces several quality of service (QoS) capabilities for virtual machines (VMs) that can be set using Windows PowerShell. One of these options is MaximumBandwidth, which is a value in bits per second. After you configure it, it ensures the VM never uses more than this amount. For example, to set this option on virtual machine VM1 and limit to 5Mbps, I would use command in this way:
Set-VMNetworkAdapter -VMName VM1 -MaximumBandwidth 5000000
To remove the limit, set the MaximumBandwidth value to 0.
Note that in addition to setting an actual limit, a better option might be to use weightings (which is a similar concept used on processor and memory) to allow certain VMs to have a greater number of network slices than other VMs in times of contention, instead of always setting a hard limit even when there is no contention.
For example use the MinimumBandwidthWeight option to set a value between 1 and 100 (0 disables the weighting) to set relative weightings between different VMs in times of network congestion. As a best practice, try and ensure weightings when added up don't exceed 100. It's a good idea to use values such as 1 and 2 for the MinimumBandwidthWeight values, unless it's highly critical, in which case use values such as 5. I've seen organization use a value of 1 for Bronze network service, 3 for Silver, and 5 for Gold.
Note that this weighting can also be used virtual network adapters not used by VMs. A single virtual network switch could be created on a converged network or NIC teamed server, and then many virtual network adapters created on the switch for purposes such as Management, VM usage, Live Migration, Cluster etc. MinumumBandwidthWeight weights can then be set on the various virtual adapters based on their types of traffic. A Microsoft blog post outlines this approach.
About the Author
You May Also Like