What is a vCPU and How to Calculate vCPU Requirements?

December 15, 2022

Introduction

A vCPU stands for virtual Central Processing Unit and represents the central processing unit used in virtual machines and cloud environments. Each vCPU in a VM's operating system represents one physical CPU core.

Businesses increasingly use VMs to save rack space and time and to reduce management costs. VMs allow users to run multiple OSes on a single physical machine, while vCPUs ensure the necessary performance.

In this article, you will learn what a vCPU is, how it compares to a CPU, and how to calculate vCPU requirements.

What is a vCPU and How to Calculate vCPU Requirements?

What is a vCPU?

A vCPU is a virtual CPU created and assigned to a virtual machine or virtualization software by a hypervisor. It represents a software implementation of a physical CPU that doesn't exist as a real CPU, but the OS sees it as a real one.

Each VM in a cloud environment gets at least one vCPU. This is possible by using a physical CPU as a virtual CPU on a server and hosting multiple VMs on it.

One of the key features of a vCPU is that it allows multiple VMs to share the host machine's physical resources which include the CPU, memory, storage, etc.

Note: Refer to our comprehensive guide to learn the difference between a CPU and GPU.

How Does a vCPU Work?

A vCPU works by occupying several time slots across all the available physical CPU cores on a host machine. That means a vCPU doesn't represent a 1:1 allocation of the physical CPU core resources. Additionally, due to the distribution across multiple cores, one vCPU has better utilization than a single physical CPU core.

The hypervisor determines which time slots a vCPU occupies and which CPU core it is currently assigned to. Such resource distribution allows multiple VMs to be hosted on a limited number of physical cores.

This feature makes it possible to run several VMs on the machine that has, for example, only two physical CPU cores.

How Many vCPUs are in a CPU?

Modern CPUs are built on integrated circuit microprocessors that contain one or more cores. Chips with more than one core are called multi-core processors, and the individual cores have multiple logical cores, all of which are used to create vCPUs.

A physical core can usually run two threads, which means it has two logical cores. This is called Hyper-Threading, and it provides more computational power and allows more concurrent VMs.

Taking all the above into consideration, the number of vCPUs in a single host machine largely depends on the following:

  • The number of physical CPUs in the host machine. There is usually one CPU per machine, but modern data centers can have single and dual processor servers.
  • The number of CPU cores. A CPU core is a processor built into the CPU chip, and each core can independently perform and process tasks simultaneously. Modern CPUs have up to 64 cores that run 128 threads.
  • The number of CPU threads. A thread is a set of instructions that allows a CPU core to be split into multiple virtual (logical) cores to increase performance. One CPU core usually has two threads. AMD uses multithreading, while Intel uses hyper-threading.

Refer to the section below to calculate how many vCPUs you need for a VM and the maximum vCPU number supported by your system.

Note: Read our article on the Linux perf command and learn to monitor CPU performance.

How Many vCPUs Do I Need and How to Calculate It?

The maximum vCPU count in a system depends on the CPU type and hypervisor manufacturer. The vCPU count is calculated by taking the number of processing threads per core and multiplying it by the number of cores and occupied CPU sockets. Therefore, the formula for calculating the vCPU count is:

(Threads x Cores) x Physical CPU Number = Number of vCPUs

For example, if a CPU has 8 cores and 16 threads, the maximum vCPU count is:

(8 Cores x 16 Threads) x 1 CPU = 128 vCPUs

The total available number of vCPUs for the example above is 128.

To find the number of cores and threads on Windows and Linux systems, follow the steps below:

Windows users:

1. Open Task Manager by pressing Ctrl+Shift+Esc.

2. Click the Performance tab and select the CPU section.

Obtaining CPU details in Windows.

3. On the bottom right, find the number of Cores, Logical Processors (Threads), and Sockets (CPU count).

The maximum vCPU number for this machine is:

(4 Cores x 8 Threads) x 1 CPU = 32 vCPUs

Linux users:

1. Open a terminal window (Ctrl+Alt+T).

2. Run the lscpu command:

lscpu
Obtaining CPU details in Linux.

The command output states the CPU details, including the number of physical CPUs, cores, and threads per core.

The maximum vCPU number for this machine is:

(4 Cores x 1 Threads) x 1 CPU = 4 vCPUs.

Calculating vCPU Number for a Particular Workload

To calculate the number of vCPUs required for a particular workload, first determine the number of physical CPU cores available on the host machine. Then, consider the expected workload for each VM you want to host.

When considering the workload, note the CPU utilization - will CPU utilization be at 100% all the time, or will there be utilization bursts? By determining the requirements, you can decide how many vCPUs to assign to which VM.

For example, small workloads with low CPU time allow having more VMs as they don't require as many resources. However, big workloads, such as database servers, have greater resource utilization, which means there will be fewer VMs on the same machine.

The minimum requirement for each VM with a small workload should be one vCPU, while additional ones can be added as the workload increases.

Conclusion

This article explained the notion of a virtual CPU, how it works, and where it is used. You also learned how to calculate the maximum number of vCPUs for a single machine or a particular workload.

Virtualization software is increasingly used for servers nowadays since it significantly saves resources, time, and money. Learn more about the software in our Virtualbox vs. VMware comparison article, or learn about server virtualization and how it works.

Was this article helpful?
YesNo
Bosko Marijan
Having worked as an educator and content writer, combined with his lifelong passion for all things high-tech, Bosko strives to simplify intricate concepts and make them user-friendly. That has led him to technical writing at PhoenixNAP, where he continues his mission of spreading knowledge.
Next you should read
How to Check CPU Temperature on Linux
March 10, 2021

Read our tutorial to learn how to monitor CPU, GPU and HDD temperatures on machines running Linux, by using different utilities.
Read more
Single vs Dual Processor Servers
February 20, 2019

Learn the differences between a single processor and a dual processor server. Make the best decision for your business and future infrastructure needs.
Read more
Check CPU Utilization in Linux
March 6, 2024

You have probably noticed your Linux OS slowing down, especially when working harder. This article shows how to check CPU usage in Linux.
Read more
Set Docker Memory and CPU Usage Limit
December 6, 2023

Docker containers have unlimited RAM and CPU access. Learn how to configure your containers to limit resource usage.
Read more