Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

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

June 19, 2023 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

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 NeededNumber of Virtual Sockets in the VM SettingsNumber of Cores per a Virtual Processor in the VM Settings
111
……
10110
11Not optimal
1226
……
20210
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.

2 comments
3
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

Reset Root Password in VMware ESXi

October 12, 2023

How to Fix ‘An Operating System Wasn’t Found’...

July 14, 2023

How to Enable and Configure Hyper-V Remote Management

June 8, 2023

Unmounting an NFS Datastore from VMware ESXi

April 21, 2023

How to Increase Virtual Machine Disk Size in...

April 6, 2023

2 comments

Harry March 12, 2021 - 8:46 am

When I first installed “Windows 10 Pro” guest on a Ubuntu host, I noticed that Windows was performing slow. Today while checking systeminfo I noticed that Windows was using only 2 cores instead of 8 as per host.
I followed your tutorial and worked. Although I had to remove previous “cpu mode” directive otherwise virsh refused to save new config.
Thank you soo much.

Reply
Diogo August 19, 2022 - 5:59 pm

Good afternoon, how are you?

And what adjustment needs to be made in Hyper-V for a virtual machine to recognize 2 sockets?

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • How to Connect VPN Before Windows Logon

    November 14, 2023
  • Removing Azure Arc Setup Feature on Windows Server 2022

    November 9, 2023
  • Using WPAD (Web Proxy Auto-Discovery Protocol) on Windows

    November 7, 2023
  • Send Emails with Microsoft Graph API and PowerShell

    November 6, 2023
  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Windows Server Licensing for Virtual Environments
  • USB Device Passthrough (Redirect) to Hyper-V Virtual Machine
  • How to Install VMWare ESXi in a Hyper-V Virtual Machine?
  • Import, Export and Clone Virtual Machines in Hyper-V
  • Hyper-V: Enabling Routing Between Internal Networks (Subnets)
  • How to Backup Hyper-V Virtual Machines (Tutorial)
  • How to Extend or Shrink Virtual Hard Disks on Hyper-V?
Footer Logo

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


Back To Top