Last week I received a very strange customer inquiry in which they would like to limit the number of physical CPU sockets seen by ESXi. As you can imagine, my interest was piqued as this is usually not the type of request you hear from customers looking to actively reduce the overall computing power of their underlying hardware, especially if they have paid for it. After digging into the details a bit more, it turns out this is related to licensing.
The customer is running an application on a VM which is licensed by the total number of underlying physical CPU sockets of the server, regardless if they are actively being used by the application or not. The vendor shall be left nameless but I am sure some of you can make some educated guesses 🙂 The customer was in the process of performing a hardware refresh where they would be moving from a 4 socket CPU to an 8 socket CPU and they would be negatively impacted by this change from a licensing standpoint. I can understand their concerns, they have now just doubled their application licensing cost without actually benefiting from the actual hardware update.
Luckily, because the customer is running vSphere ESXi, there is a neat little capability that may not be that well know which allows you to actually limit the number of physical CPUs seen by ESXi. This capability is exposed as an ESXi Advanced Setting called VMkernel.Boot.maxPCPUS and by default, this is set to unlimited as you would expect. You can change this setting using a variety of methods including the vSphere Web Client, vSphere C# Client, ESXi Embedded Host Client, vSphere API which includes ESXCLI & PowerCLI. Here is a great example in which you can actually save money by running vSphere in addition to all the other benefits 😀
Using the customer example, if I have a server that has 8 physical CPUs and I want to change that to 4 physical CPUs, then I just need to adjust the value to 4. Once you have made the change, you will need to reboot the ESXi host for the changes to go into effect and when you login to the ESXi host, you will see that the number of physical CPUs have now been reduced and no longer visible to ESXi. Another option which I have seen some postings online about which is the ability to turn off specific CPUs for certain hardware platforms using the system BIOs, having said that, I have not actually seen any real confirmation that this is in fact possible.
Note: There is no way to limit the specific number of cores on a physical CPU socket other than disabling Hyperthreading from system BIOs.
Below are screenshots using the vSphere C# & ESXi Embedded Host.
List the current configurations
esxcli system settings kernel list -o maxPCPUS
Set a new configuration
esxcli system settings kernel list -s maxPCPUS -v 4