Yesterday I started talking about how Hyper-V schedules virtual processors – and spent most of my time talking about the virtual machine reserve.  Today I would like to continue the discussion – but to now focus on the virtual machine limit.

Virtual machine limit

This is the second resource control setting that you can configure on the processor settings for a virtual machine and, like the virtual machine reserve, it is configured as a percentage of the total possible CPU usage of a virtual machine.

The virtual machine limit (or CPU limit) simply states that a virtual machine will never be allowed to use more than the specified percentage of its virtual processors – and compared to the other controls it is relatively easy to understand.

How do people use the CPU limit?

There is really only one common usage for the CPU limit – and that is for dealing with poorly written applications.

The classic scenario here is that you have a flaky application that is key to your operating environment – but every now and then it just gets confused and starts chewing up all the CPU resource it can.  In these cases – you can use the CPU limit to make sure that it does not run away with all of your system resources.

What are the common problems involved in using a CPU limit?

There are two common problems that people deal with on the CPU limit:

  • It is always enforced

    Unlike the virtual machine reserve (which is only activated when there is contention for CPU resource) the CPU limit is always active.  What this means is that if you have a virtual machine with a limit of 50% – it will be kept at 50% even if there is nothing else running on the physical computer. 

    Many people think about using the CPU limit to help deal with “untrusted” users – but the fact that it is always on makes this approach impractical.  The better approach for a configuration where you are worried about some virtual machines chewing up CPU resource that is needed elsewhere is to configure a virtual machine reserve on the virtual machines that you care about, rather than limiting the ones you do not trust

  • It is applied to each virtual processor individually

    All Hyper-V CPU resource scheduling options are applied to virtual processors individually – but it can seem a bit strange when you combine a CPU limit with a multi-processor virtual machine.  What happens here is that a dual-processor virtual machine with a limit of 50% actually gets two virtual processors that are capped at 50%.  If one processor experiences high load – it will be capped at 50% while the other processor is idle.

Tomorrow I will continue looking at Hyper-V CPU scheduling by looking at “virtual machine weight”.

Cheers,
ben