Resource Metering in Hyper-V

Posted on September 17, 2014 by Aidan Finn in Hyper-V with 0 Comments

In this blog post I will show you how you can measure the usage of host resources by Hyper-V virtual machines. This is yet another feature that was introduced in Windows Server 2012 Hyper-V that isn’t immediately obvious and is driven by using Windows PowerShell. So why should you use resource metering in Hyper-V? Read on to see why this feature is so important.

Why is Hyper-V Resource Metering Important?

The American National Institute of Standards and Technology gives us one of the best definitions of a cloud in their Special Publication 800-145, entitled “The NIST Definition of Cloud Computing.” In this document they describe a cloud as having five essential characteristics. One of the traits that they describe as being necessary to have a cloud is a measured service:

Cloud systems automatically control and optimize resource use by leveraging a metering capability at some level of abstraction appropriate to the type of service (e.g., storage, processing, bandwidth, and active user accounts). Resource usage can be monitored, controlled, and reported, providing transparency for both the provider and consumer of the utilized service.

What does this mean? A cloud enables a tenant to consume just what they need and pay for what they use. The cloud must be able to measure that usage. Using this information, a cloud vendor can charge the tenant for their resource usage.

Hyper-V resource metering

Resource metering is an important part of any Hyper-V deployment. (Image: Dreamstime)

That’s fine for a hosting company. What about in a private cloud, that is, an infrastructure that runs on premise? Traditionally the IT department is run as a cost center, or as the board of directors unfortunately see it, as a budgetary black hole. IT can change this incorrect perception in one of two ways:

  • Cross-charging: Every department that consumes IT services and resources will be given their own IT budget to spend with the IT department. IT will provide those services and resources, and invoice their internal customers on a regular basis in a non-profit manner. This changes IT into a service organization.
  • Show-back reporting: Many organizations will never consider changing IT into a chargeable service. However, IT can show the business leaders the cost of providing services to each of the business groups by reporting usage and translating that usage into a monetary value. This is a company politics move that can change the perception of IT within the business.

In my opinion, these sorts of actions could misfire and lead to talk of out-sourcing and off-shoring, so be careful!


What Information is Collected?

Resource metering will collect the following data for each enabled virtual machine:

  • Average CPU usage in MHz
  • Average physical memory usage
  • Minimum physical memory usage
  • Maximum memory usage
  • Maximum physical amount of disk
  • Total incoming network traffic
  • Total outgoing network traffic

Note that in the case of dynamic virtual hard disks, the potential size, not the actual size, is reported for maximum physical amount of disk. Also note that all data is stored with the virtual machine and moves with the virtual machine as it migrates between hosts.

Enabling and Using Hyper-V Resource Metering

Resource metering is made available using PowerShell. You can write scripts using PowerShell or you can use other tools to leverage the functionality.

You must first enable metering on a per-virtual machine basis. The following snippet will enable metering on all virtual machines on a host:

Tip: Remember to enable metering on any virtual machine created afterwards because the above cmdlet will only affect existing virtual machines.

By default, resource metering will collect metrics every hour. This is based on a per-host setting called ResourceMeteringSaveInterval. You might want to change this setting to match your billing rate in a cloud. If you are just testing resource metering, then you might want a more frequent collection. This example will change the setting to every 10 seconds:


After the resource metering interval has passed, you will want to collect some metrics. Here’s a quick way to see all collected data:

Resource Metering tracks several different metrics for Hyper-V virtual machines

Measuring resource usage by Hyper-V virtual machines. (Image: Aidan Finn)

You could do something more targeted:

You can get a breakdown of bandwidth usage using:

Armed with this information, it won’t take you too long to find resource hogs on your hosts:

Identify top offenders on your Hyper-V hosts using Resource Metering

Reporting on the top resource consumers. (Image: Aidan Finn)

Resource metering is a tool that can show the value of IT to the business or enable a service provider to earn revenue. And with this data, you even have some ability to track usage for diagnostics reasons.


Tagged with , , , , , ,