Windows – Number of logical processors per VM

central-processing-unithyper-vvirtual-machineswindows

I have a server (quad core) running Windows Hyper-V Server 2008 R2 with two Windows Server 208 R2 Standard guest virtual machines.

I've noticed the number of logical processors setting (under the Processor) settings page for each VM defaults to 1, but allows me to choose anything from 1 to 4 "virtual processors" (or "logical processors" equivalently I suppose).

My questions are: a) Do these "virtual processors"/"logical processors" map directly to cores on my Intel Q6600 quad-core CPU? b) Is it advisable to set the number to 2 for both guest VMs in this case? Does that leave sufficient CPU power for the Hyper-V host?

Along with processing power, I'm also wondering whether/how I can reserve a certain amount of RAM for the Hyper-V host.

Best Answer

It is a trade-off. Say you have four physical cores and two VMs.

If you map two virtual cores in each VM, then pretty much each guest will see what it expects. It will see two cores that it expects to have full control over and more or less get that. (Assuming host load isn't high.) You won't often confuse the guest's scheduler with a case where it assigns a task to a core expecting the task to be done immediately and instead the task does not get done because no physical core is available. However, if one guest is CPU-starved and the other is idle, two cores will be twiddling their thumbs.

On the other hand, if you give each guest four virtual cores, each guest will be able to use all the available CPU power when the other guest and the host don't need it. However, when there is load from another source, the guest's scheduler will not get the behavior it expects and some tasks will get started immediately and some won't in a way that the guest's scheduler can't easily expect and deal with.

My recommendation is generally to put as many physical cores as you have in each VM that might ever be expected to need a lot of CPU. The exception would be if you have VM's that are critically dependent on latency. I would also reduce the core count on any "smaller" or "less important" VMs that share a physical box with more critical VMs.

The hypervisor assigns logical cores to physical cores as part of its scheduling policy. There is no fixed mapping unless you specifically make one. (Which I don't recommend except in the one specific case where you want to reserve a core for a latency-critical VM.)