Resource Allocation in Hyper-V (Part 3)

by [Published on 29 Oct. 2008 / Last Updated on 29 Oct. 2008]

This article continues the resource allocation series by talking more about CPU allocation.

If you would like to read other parts to this article series please read: 

The Role of Metrics

In the previous part of this article series, explained that the various metrics that are typically used for measuring the amount of CPU time that is being consumed by virtual machines are extremely misleading. This greatly complicates the task of allocating CPU resources to the virtual machines that are running on a server, because it is difficult to figure out how much CPU time each virtual machine is actually using. Even so, there are some ways of getting the job done.

The key to allocating CPU, or any other types of resources in Hyper-V, is to remember that everything is relative. For example, Microsoft has released some guidelines for virtualizing Exchange Server. One of the things that was listed was that the overall system requirements for Exchange Server are identical whether Exchange is being run on a virtual machine, or on a dedicated server.

Assuming that the same principle applies to other types of environments, we can use basic performance monitoring within a virtual machine as a way of helping is to allocate resources to a virtual machine. For example, most of the books that I have read on performance monitoring state that, on average, no more than 80% of the CPU's resources should be consumed. If we look at the %Processor Time counter in Performance Monitor (within a virtual machine), we can see what percentage of the processor time the virtual machine thinks is in use. Keep in mind that this is not the actual amount of CPU time that is being used by the virtual machine, but it does not really matter. What is important is perception. In other words, how much CPU time does the virtual machine think that it is using?

Virtual Machine CPU Resources

Obviously, running Performance Monitor within a virtual machine is easy. The real question is what do you do if you find out that a virtual machine’s CPU resources are being over or under utilized?

As you get a feel for how a virtual machine's CPU resources are being utilized, you can allocate more or less CPU time to the virtual machine. For example, if Performance Monitor tells you that a virtual machine's CPU is constantly running at 100%, then it means that not enough CPU time is being allocated to the virtual machine, or that the server simply does not have sufficient CPU resources to support the virtual machine's needs. In either case, you would need to check to see how much CPU time is being allocated to the virtual machine. If not all of server's CPU time is being consumed, you could allocate additional CPU time to the virtual machine, which should bring down the value of the %Processor Time counter.

Before I show you how to allocate CPU resources, it is important to keep in mind that a single host operating system running Hyper-V can host multiple guest operating systems, and that resources are allocated separately for each virtual machine. Therefore, if you want to provide additional CPU resources to a particular virtual machine, you may have to take some CPU resources away from another virtual machine, so that those resources can be freed up for the virtual machine that really needs them.

Adjusting the VM CPU Resources

With that in mind, open the Hyper-V Manager, and then right click on the virtual machine that you want to adjust the CPU resources on. Select the Settings command from the resulting shortcut menu, and Windows will display the settings for the virtual machine. Keep in mind that some of the settings will not be available unless the virtual machine is shut down.

When the Settings window opens, the left side of the screen will list various system components that you can adjust the settings for. Select the Processor from the list. When you do, the right side of the screen will display some processor specific settings, as shown in Figure A.

Figure A:
You can allocate processor resources on a per virtual machine basis

As you can see in the figure above, there are several different options that you can set in regard to the CPU resources that are assigned to the virtual machine. The first setting in the list allows you choose the number of logical processors to be assigned to the virtual machine. Logical processors mirror the number of physical cores installed on the machine. For example, the server that I used to capture the screenshot above contains four processor cores. That being the case, I have the option of assigning 1, 2, or 4 logical processors to the virtual machine. In this particular case I am only assigning a single logical processor to the virtual machine, even though the machine could benefit from having multiple logical processors. The reason why am doing this is because this particular server hosts three separate virtual machines. By limiting each virtual machine to using a single logical processor, I am effectively reserving a CPU core for the host operating system, and one for each of the virtual machines.

The next setting on the list is the Virtual Machine Reserve setting. This setting allows you to reserve a percentage of the machine's overall CPU resources for this particular virtual machine. This setting is handy if you have a virtual machine that is running CPU intensive applications, and you want to ensure that it always has at least a minimal level of CPU resources available to it. Notice in the figure that the virtual machine reserve is set to zero. This means that I am not specifically reserving any CPU resources for the virtual machines.

The next setting is the Virtual Machine Limit setting. This setting is basically the opposite of the Virtual Machine Reserve setting. Rather than guaranteeing a minimal level of CPU resources, this setting prevents the virtual machine from consuming an excessive amount of the available CPU resources. If you look at the figure, you can see that the virtual machine limit is set to 100. Just beneath that the percent of total system resources set to 25. The reason for the seemingly contradictory settings is that the virtual machine is allowed to use up to 100% of the CPU resources associated with one logical processor. Since there are four logical processors in the machine, this constitutes 25% of the machine’s total CPU resources.

The last setting on the list is the Relative Weight setting. You can use this setting as an alternative to the settings that I have already discussed. The basic idea is that virtual machines with higher relative weights receive more CPU time, and virtual machines with lower relative weights receive less CPU time. By default, all virtual machines are assigned a relative weight of 100 to prevent anyone virtual machine from receiving preferential treatment.


In this article, I have explained that although it is difficult to measure the exact amount of CPU resources that are being consumed by a virtual machine, you can use the Performance Monitor to measure the relative CPU consumption. You can then use this number to help you to adjust the allocation of CPU resources for the various virtual machines hosted on the server. In the next article in this series, I will discuss memory allocation for virtual machines.

If you  would like to read other parts to this article series please read: 

See Also

The Author — Brien M. Posey

Brien M. Posey avatar

Brien Posey is an MCSE and has won the Microsoft MVP award for the last few years. Brien has written well over 4,000 technical articles and written or contributed material to 27 books.


Featured Links