CPU Hot Plug Effects on vSphere vCPU Count

The idea of hot plug, which is the live addition of a CPU to a server, was something that I never encountered prior to virtualization. None of the servers that I purchased from HP or Dell had an empty CPU socket – that seemed wasteful to me. However, it’s a rather helpful operation for a virtual machine and is often a great argument for the “start small and get larger” mentality for vCPUs.

One gotcha, however, is that it adds an entire virtual socket to the virtual machine. Prior to vSphere 5, that really wasn’t something you could see or control without digging into the advanced configuration. With 5.X, the number of virtual sockets and cores per socket are easily accessible via the GUI, which can cause a surprise when you go to perform a CPU hot plug. The only increments available are virtual sockets, so let’s run through the process.

Enabling Hot Plug

The process is straight forward. Take a powered off VM, edit the settings, and navigate to options > advanced > memory / CPU hotplug and simply enable the feature.

hot-add-cpu-option

Once done, you can power on the VM and bump up the quantity of virtual sockets at will.

In this example, I’m changing my 2 vCPU (1 socket with 2 cores) virtual machine into a 4 vCPU server (2 sockets with 2 cores). Note that the quantity of cores is grayed out – you can’t change this while the VM is online. In this case, I’m stuck with growing my vCPUs in quantities of 2.

add-cpu

Once done, Task Manager will issue a warning blurb that the quantity of CPUs has changed.

num-cpu-change

Thoughts

I feel it’s important to remember that you can only hot plug a new virtual socket, not virtual cores, into a virtual machine. If you are purposely building a VM with a low number of vCPUs because you want to start small and grow into a size “on the fly” it is worth knowing how your virtual sockets and cores are arranged. For example, if you make a single virtual socket with 8 virtual cores, you can only scale up in quantities of 8 virtual cores.