Categories
World Tech

Selecting the Number of vCPUs and Cores for a Virtual Machine

When creating virtual machines in different hypervisors (VMWare, KVM, Hyper-V, etc.), a virtual machine may not see all the virtual CPU sockets (vCPUs) assigned to it. In our case, 8 vCPUs were allocated to the KVM virtual machine and Windows 10 was installed on it as a guest operating system. However, Windows defined these vCPUs as separate processors (not cores) and only two of them could be used.

Windows 10 virtual machine with only 2 cores

If you open Windows Device Manager, you will see that all the allocated cores are visible as 8 separate QEMU version 2.5+ virtual CPUs.

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

This means that Windows 10 can only use 2 cores, no matter how many you 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 the desktop versions of Windows (Windows 10/8.1/7) have a limit on the maximum number of physical processors (sockets) a computer can use:

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

However, this limitation is not related to the number of cores. You can use a processor with more cores to improve the performance of the virtual machine. Most hypervisors can provide vCPUs as processors, processor cores, or even threads. This means that instead of 8 VCPUs, you can add 2 VCPUs (2 sockets) with 4 per socket. Let’s see how we can assign virtual processors as cores in different hypervisors and how we can link them to the NUMA architecture used in modern processors.

Virtual kernel and VCPU management in KVM

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

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

Stop your virtual machine:

# virsh shutdown w10testvm – where w10testvm is the name of your virtual machineWhere w10testvm is the control aspects of the KVM virtual machine from the console using virsh.

Displays the current XML configuration of the KVM virtual machine:

# virsh dumpxml w10testvm

We need a block that describes the parameters of the VM processor:

8

1000

/machine

hvm

As you can see, there are 8 VCPUs installed here. Let’s reconfigure this:

# virsh edit w10testvm

Add the following block after :

 

Where:

  • host-passthrough is an emulation mode in which the virtual machine sees the physical processor of the cluster node.
  • sockets=1 indicates that a vCPU (socket) is present.
  • Cores=4 The CPU has 4 cores per socket.
  • thread=2 i.e. the kernel has 2 threads

Save the configuration file and start the virtual machine. Log on to your Windows 10 guest VM, run Task Manager or Resource Monitor, and verify that Windows sees all the virtual cores involved.

The physical host CPU, Intel(R) Xeon(R) Silver 4114 CPU, is now shown in the system properties instead of the virtual CPU.

This way we could solve the problem of high VM load, since two cores were not enough for normal application operation.

Set the number of cores on the VCPU for VMWare VM

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

  1. Turn off the VM and open the settings;
  2. Expand the processor partition;
  3. Change the VM configuration so that the guest operating system can see 2 CPUs with 4 cores each. Change the value of Cores per Socket to 4. This means that the guest operating system sees two 4-core CPUs (2 sockets with 4 cores per socket);
  4. Save the changes and start the VM.

Virtual machine vCPU and NUMA architecture

There are a few other aspects of allocating vCPUs and cores to virtual machines that you need to understand.

When assigning the number of cores per socket, make sure you have the NUMA architecture (used in most modern processors). It is not recommended that a VM be allocated more cores per socket (and total number of vCPUs) than are available on the physical socket (NUMA node). When a virtual machine is hosted on a single physical NUMA node, it can use the fast local RAM available on a particular NUMA node. Otherwise, the processes must wait for a response from another NUMA node (which takes more time).

If you assign two separate virtual sockets to a VM, the hypervisor can run them on different NUMA nodes. This affects the performance of the VM.

If the number of vCPUs required exceeds the number of cores on a physical socket (NUMA node), create multiple virtual sockets (processors) with the required number of cores. It is also not recommended to use an odd number of processors (it is better to add 1 vCPU).

This preserves the performance of the virtual machine.

That’ll be z. B. recommends using the following configuration for a host with 2 processors and 10 cores per socket (a total of 40 vCPUs available, including Hyper-Threading) when configuring vCPUs for a VM:

The number of VCPUs required Number of virtual sockets in the VM settings Number of cores per virtual processor in the virtual machine settings
1 1 1
……
10 1 10
11 Not optimal
12 2 6
……
20 2 10

In the free version of ESXi, you cannot create a VM with more than 8 VCPs.

For example, a VM running Microsoft SQL Server 2016 Enterprise Edition with 16 VPSs (in an 8-socket configuration with 2 cores per socket) has lower performance than a VM with 2 sockets x 8 cores per socket.
Also consider that some applications are licensed based on the number of physical sockets (as was the case in previous versions of SQL Server). Sometimes it is more cost effective to license a multi-core processor than multiple processors with fewer cores. Modern versions of Windows Server are specifically licensed in a virtual environment.

frequently asked questions

How many vCPUs can you have on a virtual machine?

2014/01/18 decide …

How many hearts should I give to my VM?

Questions like Man Virtue Pro…

How many processors are in the processor?

What, what, what, what, what, what, what?

Related Tags:

Feedback,physical cpu to vcpu calculator vmware1 vcpu = how many cores gcp1 vcpu = how many cores aws1 vcpu = how many cores vmware4 vcpu how many cores1 vcpu = how many cores azure,People also search for,Privacy settings,How Search works,physical cpu to vcpu calculator vmware,1 vcpu = how many cores gcp,1 vcpu = how many cores aws,1 vcpu = how many cores vmware,4 vcpu how many cores,1 vcpu = how many cores azure,physical cpu to vcpu calculator hyper-v,vcpu to core ratio

Leave a Reply

Your email address will not be published.