VMware Cloud Community
Contributor
Jump to solution

## Using CPU shares

Hi Folks,

i am learning towards my VCP-DCV 550 exam and I have a question regarding shares for which I did not find an answer:

How do shares work when I have VMs with different numbers of vCPUs allocated?

Lets assume that I have a host with 5x VMs and the host has a single quad core processor with 4GHz. (4x4GHz =16GHz total host CPU resources)

VM1-2-3-4: each VM is configured with 1x vCPU and CPU reservation of 1000Mhz (per VM) shares are set to normal (1000 shares)

VM5: is configured with 4x vCPU and a CPU reservation with 1000MHz, shares are set to normal (1000 shares)

the running VMs have a total reservation of 1000+1000+1000+1000+ 4x1000 MHz = 8000MHz

But how are the remaining  8GHz host CPU resources allocated between the VMs (assuming all VMs are busy and in the state of CPU contention)?

Thanks for the clarification!

BR

Janos

Tags (2)
1 Solution

Accepted Solutions
Immortal
Jump to solution

Welcome to the Community - where the confusion is coming form is that shares are not really clock cycles but a percentage of available clock cycles - think of the total number of cycles as a pie of the amount of shares determine how the pie the divided when there is contention - so with your example each vcpu can occupy an entire core and you have total of 8000 shares -when all vcpus need a full core the CPU cycles will get divided like this   a single vcpu vm will get 1000/8000 of the available cpu cycles when there is contention and the quad vcpu will get 4000/8000 or 1/2 of the available cycles

hope this helps

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
3 Replies
Immortal
Jump to solution

Welcome to the Community - where the confusion is coming form is that shares are not really clock cycles but a percentage of available clock cycles - think of the total number of cycles as a pie of the amount of shares determine how the pie the divided when there is contention - so with your example each vcpu can occupy an entire core and you have total of 8000 shares -when all vcpus need a full core the CPU cycles will get divided like this   a single vcpu vm will get 1000/8000 of the available cpu cycles when there is contention and the quad vcpu will get 4000/8000 or 1/2 of the available cycles

hope this helps

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
Enthusiast
Jump to solution

Read it!  Keep it on the shelf when done.

http://www.amazon.com/VMware-vSphere-5-1-Clustering-Deepdive-ebook/dp/B0092PX72C

------ tedg Don't forget to mark posts as helpful or correct if they deserve it!
Contributor
Jump to solution

Thanks Weinstein!

i got the implicit information from your answer, that when you create a single vCPU VM with normal shares than it gets 1000 shares, when you create a VM with #X vCPUs than that one gets X x 1000 shares.

I actually tried it (with a 2x vCPU and a 1x vCPU VM) and the 2x vCPU VM got 2000 shares (when set on normal) and the 1x vCPU VM got 1000 shares (when also set on normal).

So when I have a VM which has 2x vCPUs than in the case of contention it will be able to draw 2x more additional cycles over reservation than a 1x vCPU VM. This is also analogous with the way the default memory shares work

(default memory shares = 10x amount of Megabytes the VM is created with)

Which perfectly makes sense and now my question is fully answered!

Thanks!

Janos