Jun 01 2014

vSphere VM vCPU to ESXi host CPU 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 / 3:1
  • Mixed server environment / 4:1 to 10:1 / 5:1
  • 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



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.


1 ping

Skip to comment form

  1. virtualrol

    Magnus, grear report, tnx 4 Sharing 🙂

  2. Lara

    Hurrah! Finally I got a web site from where I can truly get useful data concerning my study and knowledge.

  3. magander3

    Thanks Lara. Glad you find my blog useful.


  4. Not an Expert

    Got this error when executing the script:

    Measure-Object : Property “NumCPU” cannot be found in any object(s) input.
    At D:CPUReportCPUReport.ps1:38 char:70
    + $clu.”ESXi host num CPU core” = ($clust | Get-vmhost | Measure-Object <<<< -sum NumCPU).sum
    + CategoryInfo : InvalidArgument: (:) [Measure-Object], PSArgumentException
    + FullyQualifiedErrorId : GenericMeasurePropertyNotFound,Microsoft.PowerShell.Commands.MeasureObjectCommand

  5. magander3

    what did you change in the script? If i just copy and paste the script it will run just fine.


  6. Santos

    Hi there, I discovered your site by way of Google whilst searching for a related
    topic, your web site came up, it seems great. I’ve bookmarked it
    in my google bookmarks.
    Hi there, simply became alert to your weblog through Google, and found that it is truly informative.
    I am gonna watch out for brussels. I’ll be grateful should you continue this in future.
    Lots of people can be benefited out of your writing.


  7. Rahul

    This is a great post!!
    are you aware of how to modify CPU’s for a particular VM via cli?
    I can do it via vsphere, but cli would be awesome!
    Thanks in advance

  8. magander3

    Thanks. Yes you can use PowerCLI and the set-vm cmdlet. See https://www.vmware.com/support/developer/PowerCLI/PowerCLI55/html/Set-VM.html?vmw_so_vex_mande_12


  9. Rahul

    Thanks for the quick reply. Can I use esxi based cli (ssh to esxi and run some command there?).

  10. magander3

    do you need to perform the action from within the ESXi? If so you could edit the VM .vmx file but that requires the VM to be powered off and powered on.


  11. Rahul

    I dont want to edit the vmx file, I would prefer any esxcli or vim-cmd kind of commands to do the same. Thanks for the help.

  12. Ali

    Thank you for your insightful post. following questions:

    can we have something like this for AHV?
    I am sizing a generic workload with 3:1 (vCPU:pCore)?

  13. magander3

    the only place I know that is mentioned is in the Nutanix AHV Best Practice Guide but the figures are pretty much the same.


  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! […]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">