pCPU vs vCPU Capacity Planning with VMware

I am finally getting around to digging into our datacenter environment and looking at capacity planning.. I wanted to know how many “logical” processors were in the environment compared to how many virtual CPUs I have allocated. I found the base of this script just searching around the internet and modified the math to multiply the “NumCpu” host property by 2 which gives me the logical or hyper threaded physical CPU count. I usually like to give credit to the site, but for the life of me I can’t find it again.. Lol..

I’ve read a few blog posts that try to put a hard fast 3:1 or 5:1 ratio rule to this, but it really just depends on your environment. If most of your CPUs lay idle, you can way over provision this and never really have a problem. Just watch out for that day all of your VMs go to request CPU simultaneously. I plan to dig into the following article much deeper as it seems like the way to go moving forward for capacity planning.

“Drive by contention” using resource pools: Click Here

Until then, this script will help a lot in getting a feel for how many vCPUs you have allocated vs logical/physical. It writes a CSV file to the same directory it is run from giving you the Logical core count, virtual CPU count, Ratio, and over provisioned percentage.


&{ForEach ($esx in Get-VMHost) { 
     $vCPU = Get-VM -Location $esx | Measure-Object -Property NumCpu -Sum | select -ExpandProperty Sum 
	 $esx | Select Name, 
   @{N='pCPU logical cores available';E={[Math]::Round(2*$_.NumCpu, 1)}}, 
         @{N='vCPU assigned to VMs';E={$vCPU}}, 
         @{N='Ratio';E={[math]::Round($vCPU/(2*$_.NumCpu),1)}}, 
   @{N='CPU Overcommit (%)';E={[Math]::Round(100*(($vCPU - (2*$_.NumCpu)) / (2*$_.NumCpu)), 1)}} 
}} | Export-Csv report.csv -NoTypeInformation -UseCulture

Regards,
Adam Tyler

Leave a Reply