How to assign vCPUs for Hyper-V (Part 1 of 2)

If your IT environment is like the vast majority of growing shops these days, you are probably considering, in the process of, or already managing some virtualized resources. Virtual machines are being used for a wide range of functions including application servers, file servers, database servers, email servers, and more.

In this article we will cover resource assignment specifically for Server 2012 R2 Hyper-V virtual guests.

As you consider your hypervisor host environment, there are many resources you need to plan to service your virtual guests. Of course you need to allocate memory and disk space available to your host for virtual disks, but one resource we will focus on today is virtual processors.

To assign vCPUs to a virtual machine, you will need to use the Hyper-V Manager application or PowerShell command Set-VM. If you wish to increase or decrease the number of vCPUs assigned to a virtual machine, you must first insure the machine is not running. It is preferable to perform a shutdown rather than a power off so that the running OS and applications are given a chance to quiesce in a sane fashion and avoid any potential corruption or data loss. You also need to know the total number of physical cores available in your physical host machine, as you cannot subscribe more vCPUs to a single virtual machine than are available in the host system. You can easily query the number of physical processors available via the host with this PowerShell command:

You can also find information on the physical characteristics of your host server via Server Manager  > Tools > Performance Monitor.

As you can see, my host has 4 cores. So any single virtual machine running on my host can be assigned no more than 4 CPUs. However, I can have multiple virtual machines that are assigned 4 vCPUs. You might wonder how this works. In this scenario where more processors are assigned than are physically available, the host operating system schedules tasks and threads and directs traffic requested by all the assigned and allocated vCPUs. As you can imagine, performance of individual guests may be impacted if you have many guests with oversubscribed vCPU counts, as the host has to queue the requests and assign resources to process them as quickly and logically as it can. This is why you need to consider spreading out heavy CPU usage as much as you can, either to multiple hosts or to different peak times so that all requests are load balanced as much as possible.

Interested in Free Hyper-v Backup?

Make sure to check back for part 2 of this series.

MARKET-LEADING BACKUP AND RECOVERY SOLUTIONS

Discover how Unitrends can help protect your organization's sensitive data