How to assign CPUs to virtual machines

CPU and VMsHi,
 I have a new server running Hyper-V 2019 and it came with two Intel Silver 4110  @2.1Ghz (8 core) CPUs and 64GB of RAM.
 I have 4 virtual machines - (1) Domain Controller (2) Application Server (just files and folders)  (3) Remote Desktop Server (for two remote users running Word/Excel)  (4) Windows 10 (only used if & when I need to do some testing). There are 8 users on the network.
 I am curious what would be best way to assign CPUs to VMs since there are two physical CPUs.
 Currently each VM has 1 virtual processors as I accepted "default value" when creating these VMs except manually assigned RAM amount.
 
Thanks.
LVL 1
sgleeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Adam BrownSenior Systems AdminCommented:
You have 2 physical CPU slots with 8 CPU cores each. This means you can assign up to 32 Virtual CPUs...theoretically. Realistically, you can assign 16 virtual CPUs without risking VMs walking over each other.

Assigning CPUs based on "Thread" count (Each CPU Core can operate on two operations at the same time, each operation is referred to as a thread) is okay, but you run greater risk of VMs competing for resources as you go beyond the number of physical CPUs assigned to VMs.

Basically, you can assign 4 cores to each VM that you have easily, and potentially double the number of VMs you have with 4 cores assigned to each VM without suffering a massive performance drop off.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kevinhsiehCommented:
You bought way too much CPU for current workloads. If you set your BIOS to allow CPU to sleep, that will save a little bit on your power bill. YOu can literally run 10 x or more VMs on the given CPU. RAM and storage is another issue.

General best practice is to assign 1 vCPU per VM, unless the VM has a demonstrated need for more. This rule really applies if you have more VMs than physical cores. The hypervisor needs to schedule all cores assigned to a VM before it can execute anything. As an extreme example, imagine that you have two VMs, each with 24 vCPU assigned. A hypervisor can't schedule a single core for the VM, even if it's only 1 thread in the VM that needs CPU time. The hypervisor needs to schedule all cores at once before the VM can execute anything. This means that the other VM can't do anything at that time, as there aren't enough physical cores to support both VMs and the hypervisor at the same time. Each VM would spend at least 50% of the time waiting for its turn to get CPU time.

In your case though, if each VM got 2 vCPU, that would be only half of the total available physical cores, so they could all run at 100% which would still leave half of the CPU power left for the hypervisor. This is ignoring hyperthreading.

I will often give 2 vCPU to Windows VMs just so Windows Updates runs faster. Windows Updates is significantly faster with 2 vCPU over 1 vCPU. Most other things don't seem to matter much, unless you have a busy Exchange Server.
Philip ElderTechnical Architect - HA/Compute/StorageCommented:
(1) Domain Controller - 2 vCPUs 2GB vRAM
(2) Application Server (just files and folders)   - 2 vCPUs 4GB vRAM
(3) Remote Desktop Server (for two remote users running Word/Excel)   - 2 vCPUs 8GB vRAM - 16GB vRAM (depends on user experience)
(4) Windows 10 - 2 vCPUs 4GB vRAM

If there's a database setup with management such as Sage/Intuit in #2 then bump that up to 8GB vRAM.
Mal OsborneAlpha GeekCommented:
You have  a LOT of cores there, for the VMs you have in use.  I typically use a 2:1 overcommit, but in your case it might be better to just use 1:1, assuming the W10 box is not running.  

So, I suppose:
RDP server: 16 cores.
DC: 8 cores
App server: 8 cores.
W10 box 8 cores.

This means every VM has way more cores that it is ever likely to need.

Another option might be to disable hyperthreading, and allocating half the number of cores to each VM. Hyperthreading gives you double the number of cores, however the additional ones are quite a bit slower than the base ones. Thus, you will possibly get better single core performance, if some application pegs a core.
Philip ElderTechnical Architect - HA/Compute/StorageCommented:
I suggest starting with the configuration I mentioned. Assigning too many vCPUs to a VM can actually have a detrimental effect on performance.

I have two very thorough EE articles on all things Hyper-V:

Some Hyper-V Hardware and Software Best Practices
Practical Hyper-V Performance Expectations

Some PowerShell Guides:
PowerShell Guide - Standalone Hyper-V Server
PowerShell Guide - New VM PowerShell
PowerShell Guide - New-VM Template: Single VHDX File
PowerShell Guide - New-VM Template: Dual VHDX Files

Here are some focused articles:
Slipstream Updates Using DISM and OSCDImg

Protecting a Backup Repository from Malware and Ransomware

Disaster Preparedness: KVM/IP + USB Flash = Recovery. Here’s a Guide
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.