Windows OS Hub
  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange

 Windows OS Hub / Virtualization / Selecting the Number of vCPUs and Cores for a Virtual Machine

August 18, 2020 Hyper-VKVMVirtualizationVMWare

Selecting the Number of vCPUs and Cores for a Virtual Machine

When creating virtual machines in different hypervisors (VMWare, KVM, Hyper-V, etc.), you may see that sometimes a virtual machine may not see all virtual processor sockets (vCPU) assigned to it. In our case, 8 vCPUs were assigned to a KVM virtual machine and Windows 10 was installed on it as a guest OS. However, Windows detected these vCPUs as separate processors (not cores) and it could use only 2 of them.

Contents:
  • Windows 10 Virtual Machine Using Only 2 Cores
  • Number of Processors Supported in Windows
  • Managing Virtual Core & vCPU in KVM
  • Setting the Number of Cores per vCPU for a VMWare VM
  • Virtual Machine vCPU and NUMA Architecture

Windows 10 Virtual Machine Using Only 2 Cores

If you open Windows Device Manager, you can make sure that all allocated cores are visible as 8 separate virtual processors QEMU Virtual CPU version 2.5+.

QEMU Virtual CPU version 2.5 multi processor virtual machine on KVM

At the same time, Windows 10 properties (Computer -> Properties) and Task Manager show that only 2 QEMU Virtual processors are available.

Windows Virtual Machine Sees Only 2 processors

It means that Windows 10 is able to use only 2 cores no matter how many of them you will add. At the same time, a virtual server running Windows Server 2016 on the same hypervisor can see all 16 vCPUs allocated to it.

Number of Processors Supported in Windows

The problem is that desktop Windows versions (Windows 10/8.1/7) have a restriction on the maximum number of physical processors (sockets) a computer can use:

  • Windows 10 Home – 1 CPU
  • Windows 10 Professional – 2 CPU
  • Windows 10 Workstation – up to 4 CPU
  • Windows Server 2016 – up to 64 CPU

However, this restriction is not related to the number of cores. In order to improve the performance of your virtual machine, you can use a processor with more cores. Most hypervisors can provide vCPUs as processors, processor cores or even threads. It means that instead of 8 vCPUs, you can add 2 vCPUs (2 sockets) with 4 per socket. Let’s see on how to assign virtual processors as cores in different hypervisors and how to bind it to the NUMA architecture used in modern processors.

Managing Virtual Core & vCPU in KVM

In my KVM virtual machine running Windows 10, all assigned virtual cores are considered as separate processors.

To use all CPU resources allocated to a virtual machine, it must see one 8 core processor, 2 vCPUs with 4 cores each or 1 vCPU with 4 cores in two threads instead of 8 vCPUs. Let’s try to change the allocation of virtual cores for the KVM virtual machine.

Shut down your virtual machine:

# virsh shutdown w10testvm – where w10testvm is the name of your virtual machine

Here are the aspects of a KVM virtual machine management from the console using virsh.

Display the current XML configuration of the KVM virtual machine:

# virsh dumpxml w10testvm

We need a block describing the VM CPU settings:

<vcpu placement='static'>8</vcpu>
<cputune>
<shares>1000</shares>
</cputune>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.6.0'>hvm</type>
<bootmenu enable='yes'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>

As you can see, 8 vCPUs are set here. Let’s change the configuration:

# virsh edit w10testvm

Add the following block after </features>:

<cpu mode='host-passthrough' check='none'>
<topology sockets='1' cores='4' threads='2'/>
</cpu>

Where:

  • host-passthrough is the emulation mode in which the virtual machine sees the physical processor of the cluster node
  • sockets='1' indicates that there is one vCPU (socket)
  • cores='4' the processor has 4 cores per socket
  • threads='2' ieach core has 2 threads

Save the configuration file and start the virtual machine. Log in to the Windows 10 guest VM, run Task Manager or Resource Monitor, and make sure that the Windows sees all allocated virtual cores.

virtual machine virtual sockets vs cores per socket

A physical processor of the host, Intel(R) Xeon(R) Silver 4114 CPU, is now displayed instead of a virtual one in the system properties.

Intel(R) Xeon(R) Silver 4114 multi core CPU on virtual macnine

Here is how we managed to solve the heavy load issue for the VM since two cores have not been enough for the apps to work properly.

Setting the Number of Cores per vCPU for a VMWare VM

You can change the way of vCPU presentation for a VMWare virtual machine in the vSphere Client interface.

  1. Shut the VM down and open its settings;
  2. Expand the CPU section;
  3. Change the VM configuration so that the guest OS can see 2 processors with 4 cores each. Change the value Cores per Socket to 4. It means that the guest OS will see two 4-core CPUs (2 sockets with 4 cores per socket); Changing the number of cores per CPU in a VMWare virtual machine
  4. Save the changes and run the VM.

Virtual Machine vCPU and NUMA Architecture

There are some more aspects of assigning vCPUs and cores to virtual machines that you must understand.

When assigning the number of cores per socket, make sure whether you have NUMA architecture (used in most modern CPUs). It is not recommended to assign more cores per socket (and the total number of vCPUs) to a VM than the number of cores available on your physical socket (NUMA node). When placed on a single physical NUMA node, a virtual machine will be able to use fast local RAM available on the specific NUMA node. Otherwise, processes will have to wait for the response from another NUMA node (that takes longer time).

If you assign two separate virtual sockets to a VM, the hypervisor can run them on different NUMA nodes. It will affect the VM performance.

If the number of vCPUs needed is more than the number of cores on 1 physical socket (NUMA node), create several virtual sockets (processors) with the necessary number of cores. Also it is not recommended to use an odd number of processors (it is better to add 1 vCPU).

It allows to maintain the virtual machine performance.

virtual machine vCPU nubmer and NUMA architecture

For example, it is recommended to use the following configuration for a 2-processor host with 10 cores per socket (40 vCPUs are available in total including Hyper—Threading) when you configure vCPUs for a VM:

vCPU Number Needed Number of Virtual Sockets in the VM Settings Number of Cores per a Virtual Processor in the VM Settings
1 1 1
……
10 1 10
11 Not optimal
12 2 6
……
20 2 10
In a free ESXi version you cannot create a VM with more than 8 vCPUs.

For example, a VM running Microsoft SQL Server 2016 Enterprise Edition with 16 vCPU (in the configuration of 8 Sockets with 2 Cores per Socket) will have poorer performance that a VM with 2 Sockets x 8 Cores per Socket.
Also remember that some applications are licensed depending on the number of physical sockets (like it was in earlier SQL Server versions). Sometimes it is more profitable to license one multicore processor than multiple processors with the less number of cores.

Modern Windows Server versions are licensed in a virtual environment in a special way. Also there are some aspects of processor licensing in VMWare vSphere.

0 comment
1
Facebook Twitter Google + Pinterest
previous post
How to Mount Google Drive or OneDrive in Linux?
next post
Using Saved Queries in ADUC MMC (Active Directory User and Computers)

Related Reading

USB Device Passthrough (Redirect) to Hyper-V Virtual Machine

January 15, 2021

How to Extend or Shrink Virtual Hard Disks...

December 10, 2020

FAQ: Live Migration of Virtual Machines with VMWare...

November 19, 2020

VMWare Error: Unable to Access a File Since...

October 1, 2020

How to Enable and Configure SNMP on VMWare...

September 7, 2020

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange
  • Windows 10
  • Windows 8
  • Windows 7
  • Windows Server 2016
  • Windows Server 2012 R2
  • Windows Server 2008 R2
  • PowerShell
  • VMWare
  • MS Office

Recent Posts

  • How to Sign a PowerShell Script (PS1) with a Code Signing Certificate?

    February 25, 2021
  • Change the Default Port Number (TCP/1433) for a MS SQL Server Instance

    February 24, 2021
  • How to Shadow (Remote Control) a User’s RDP session on RDS Windows Server 2016/2019?

    February 22, 2021
  • Configuring PowerShell Script Execution Policy

    February 18, 2021
  • Configuring Proxy Settings on Windows Using Group Policy Preferences

    February 17, 2021
  • Updating Group Policy Settings on Windows Domain Computers

    February 16, 2021
  • Managing Administrative Shares (Admin$, IPC$, C$, D$) in Windows 10

    February 11, 2021
  • Packet Monitor (PktMon) – Built-in Packet Sniffer in Windows 10

    February 10, 2021
  • Fixing “Winload.efi is Missing or Contains Errors” in Windows 10

    February 5, 2021
  • How to Move (Clone) Windows to a New Hard Drive (HDD/SSD)?

    February 4, 2021

Follow us

woshub.com
  • Facebook
  • Twitter
  • RSS
Popular Posts
  • How to Stop/Kill a Stuck Virtual Machine on Hyper-V?
  • Windows Server Licensing for Virtual Environments
  • How to Backup Hyper-V Virtual Machines?
  • USB Device Passthrough (Redirect) to Hyper-V Virtual Machine
  • How to Extend or Shrink Virtual Hard Disks on Hyper-V?
  • Hyper-V Boot Error: The Image’s Hash and Certificate Are not Allowed
  • How to Install and Configure Free Hyper-V Server 2019/2016?
Footer Logo

@2014 - 2018 - Windows OS Hub. All about operating systems for sysadmins


Back To Top