vSphere VM vCPU to ESXi host pCPU core allocation

There has been quite a lot of discussion regarding resource utilization and resource allocation in vSphere environments lately. There are a lot of tools around doing analysis (some better than others) of your environment and gives suggestions if you need to e.g.:

  • Add more resources (CPU, RAM, Disk, Network) to your vSphere cluster.
  • Down size one or more virtual machines (VMs)
  • Give one or more VMs more resources.

In some products you can also schedule a potential VM reconfiguration task which can be very useful if you are allowed to perform such tasks automatically.

Well this post was suppose to cover the VM vCPU to ESXi host CPU core allocation and since i receive questions about that topic at least every other week so i thought it was time to create a blog post about my experiences in this topic. The below figures are actual figures i have collected over the years from my customers.

Type of workload – Number of vCPUs per ESXi host CPU core / Most common VM vCPU to ESXi host CPU core

  • Business/Mission critical workload that are sensitive to latency – 1:1 / 1:1
  • Computation-intensive workload – 1:1 to 3:1 / 2:1
  • Server production workload / 2:1 to 6:1 / 4:1
  • Mixed server environment / 4:1 to 10:1 / 5:1
  • RDSH / 2:1
    • Windows 2008R2 = 4 vCPU/25 users per VM
    • Windows 2012R2 = 8 vCPU/50 users per VM
  • Desktop environment / 1:1 to 18:1 / 6:1

Maximum number of VM vCPUs per ESXi host CPU core is 32 according to the vSphere 5.5 configuration maximum pdf found here.

Whenever me and my customer can’t use a software that can provide you the VM vCPU to ESXi host CPU core allocation i have over the past years used a PowerCLI script that creates a report acceding to the following:

Screen Shot 2014-04-29 at 23.39.48

The “VM vCPU” column is only there to give you an idea of the worst case scenario. The column “VM vCPU on” is used to calculate the allocation. The report does not take into account if hyper-threading is activated or not.  It only presents the sum of all ESXi host CPU cores available in each cluster. Things like vSphere High Availability (HA) is also excluded in the above calculation.

This gives you an easy overview of your current VM vCPU to ESXi host CPU core allocation and if you save a e.g. monthly reports you got pretty good statistics which can be used for capacity planning or troubleshooting purposes.

My own experience tells me that vSphere environments running production workloads and a VM vCPU to ESXi host CPU core allocation equals to or less than 3:1 have had few performance related problem over the years. Remember these are my experiences form my customers environments and this might not be applicable for your specific environment.

Below you’ll find the script you can use to create the above presented VM vCPU to ESXi host core allocation report on a daily, weekly, monthly, yearly or whatever interval you want. The below script saves one report per month based on the date, 01.

My blog post “Schedule PowerCLI script in Windows task scheduler” can be used if you want to schedule the PowerCLI script in Windows Task Scheduler.

Change the following parameters to match your environment:

  • $vcenter = vc01.vcdx56.com
  • $vcenteruser = vcdx56\magnus”
  • $vcenterpw = “not secret”
  • $reportdir = c:\vSpherereport
  • $filename = c:\vSphere$date.html
  • $basefile = c:\vSpherereportCPU-oversubscription.html


# The script will calculate the ESXi host CPU core to VM vCPU oversubscription and create a HTML report
# Version 1.0 Magnus Andersson RTS
# Start of script parameters section
# vCenter Server configuration
$vcenter = “vc01.vcdx56.com“
$vcenteruser = “vcdx56magnus“
$vcenterpw = "notsecret"
$date=get-date -uformat %Y-%m-%d
# Define report directory
$reportdir = "c:\vSpherereport"
# Define file name
$filename = "c:\vSphere$date.html"
# Define base file
$basefile = "c:\vSpherereportCPU-oversubscription.html"
# End of script parameter section
#—————————————— #
# Connect to vCenter Server
connect-viserver $vcenter -User $vcenteruser -Password $vcenterpw
function Get-Cluster-CPUMem {
$table = @()
foreach($clust in (get-cluster | Sort-Object Name)) {
$esx = $clust | Get-VMHost
$clu = "" | select Cluster, "ESXi host num CPU core", "VM vCPU", "VM vCPU on", "Percent of vCPU on"
$vms = $clust | get-vm
$clu.Cluster = $clust.Name
$clu."ESXi host num CPU core" = ($clust | Get-vmhost | Measure-Object -Sum NumCPU).Sum
$clu."VM vCPU" = ($vms | Measure-Object -Sum NumCPU).Sum
$clu."VM vCPU on" = ($vms | ?{$_.PowerState -eq "PoweredOn"} | Measure-Object -Sum NumCPU).Sum
$clu."Percent of vCPU on" = "{0:P0}" -f ($clu."VM vCPU on" / $clu."ESXi host num CPU core")
$table += $clu
$clu = "" | select Cluster, "ESXi host num CPU core", "VM vCPU", "VM vCPU on", "Percent of vCPU on"
$clu.Cluster = "Total"
$clu."ESXi host num CPU core" = ($table | Measure-Object -property "ESXi host num CPU core" -sum).sum
$clu."VM vCPU" = ($table | Measure-Object -property "VM vCPU" -sum).sum
$clu."VM vCPU on" = ($table | Measure-Object -property "VM vCPU on" -sum).sum
$clu."Percent of vCPU on" = "{0:P0}" -f ($clu."VM vCPU on" / $clu."ESXi host num CPU core")
$table += $clu
$a = "<style>"
$a = $a + "BODY{background-color:white;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 4px;border-style: solid;border-color: black;}"
$a = $a + "TD{border-width: 1px;padding: 4px;border-style: solid;border-color: black;text-align:center;}"
$a = $a + "</style>"
Get-Cluster-CPUMem | ConvertTo-HTML -head $a -Title "CPU oversubscription report $date" | Out-File $filename
Remove-Item $basefile
Copy-Item $filename $basefile
if ($filename -like "*-01.*") {
Copy-Item $filename $reportdir
Remove-item $filename


Thanks to the VMware community for providing input to the script. I’m also working on a blog post where a specific product is used to create these kind of reports plus forecast reports and i think/hope you will find that one really interesting so stay tuned.

14 pings

Skip to comment form

  1. Tech Blast #11 - Browncoats Unite | Wahl Network

    […] vSphere VM vCPU to ESXi host CPU core allocation – Magnus Andersson, a VCDX, writes up a great post on the topic of vCPU to pCPU relationships, including a script to calculate the oversubscription ratios and create an HTML report. That’s awesome! […]

Comments have been disabled.