Titus Cheung wrote:
Hi, I'm running ESXi 4 on a single chip 4-core Xeon. On this ESXi, there are 4 VMs provisioned with the following setup:
Guest VMs | Shares | Shares Value | % Shares | vCore |
---|
VM1 | Normal | 1000 | 14 | 1 |
VM2 | Normal | 1000 | 14 | 1 |
VM3 | High | 4000 | 57 | 2 |
VM4 | Normal | 1000 | 14 | 1 |
Now the processes that are running on these 4 VMs can in reality be installed on the server itself under the same OS without ESXi. Doing so, I know anyone of the processes running on these VMs will have access to any 1 of the 4 physical cores on the phyical CPU. However, by installing them onto 4 VMs, it appears I'm limiting the physical resource available to only 1 of the physical cores for 3 of the VMs, and 2 of the physical cores for 1 of the VM.
So if VM2, VM3, and VM4 are extremely quiet at the moment and VM1 becomes very busy, processes on VM1 will still have access to only 1 of the 4 physical cores resource and have to wait in line to be processed since there is at most only 1 physical core? If VM1, VM2, and VM4 are extremely quiet when VM3 becomes very busy, processes on VM3 will have access to only 2 of the 4 physical cores resource so two processes can be processed in parallel? If settings for "Shares", "Shares Value", and "% Shares" do not affect the number of cores each of the VM have access to, how does it changes things given the setup above?
In the end, if I want VM1 - VM4 to have access to all the physical cores, I should set them each to have 4 vCores?
The shares only come into play when the CPU is overcommitted. As long as there are available processor resources, every VM will have 100% of its allocation available to it at a given time... so if you have a 2000Mhz 6-core processor, VMs 1, 2, and 4 will have 2000Mhz available to each, and VM 3 will have 4000Mhz. After the point of CPU contention, if VMs are continuing to request physical CPU, then CPU resources will be granted based on their shares. "High" gets twice as many of the contended CPU cycles as "Normal".
When you allocate a core to a VM, it is true that it will only have access the number of cores that you allocated at any given time, but it will not remain bound to the same physical core necessarily, over time. When a VM has something to process, the VMkernel decides which core the VM will access to execute that command. If a VM has multiple cores, the VM will not be able to process an instruction unless it can access the number of cores that it was allocated, simultaneously. So, unless you really NEED multiple cores, it is not recommended to allocate more than one.