VMware Cloud Community
zenomorph
Contributor
Contributor
Jump to solution

ESX CPU sharing

I'd like to clarify something on CPU sharing.

If I have a single Quad Core CPU ESX running 3 VMs with the following CPU allocation

VM1 - 1CPU

VM2 - 2CPU

VM3 - 4CPU

how does ESX actually go about sharing the Quad Core CPU among the VMs assuming all the VMs are CPU intensive, does it allocate each VM a specific time slice or?

Can someone please explain this for me.

Many thanks

0 Kudos
1 Solution

Accepted Solutions
RParker
Immortal
Immortal
Jump to solution

how does ESX actually go about sharing the Quad Core CPU among the VMs assuming all the VMs are CPU intensive, does it allocate each VM a specific time slice or?

Same way Linux / Windows treats processes for threading, time slice. ESX works the same way, it treats VMs like processes, so it threads them across all the CPU according to priority.

View solution in original post

0 Kudos
8 Replies
RParker
Immortal
Immortal
Jump to solution

how does ESX actually go about sharing the Quad Core CPU among the VMs assuming all the VMs are CPU intensive, does it allocate each VM a specific time slice or?

Same way Linux / Windows treats processes for threading, time slice. ESX works the same way, it treats VMs like processes, so it threads them across all the CPU according to priority.

0 Kudos
weinstein5
Immortal
Immortal
Jump to solution

to add the vmkernel will also follow some guidelines - the vcpu of a vcpu will never run on the same core - so the quad vcpu vm will have each of its vcpus running on different cores, the serice console will alwys run on the first core cpu0, and the vmkernel will spread its load across all four cores. In terms of scheduling the vcpus of a virtual smp vm is they will get scheduled silmultaneously so if the virtual cpus of vm2 and vm3 can not be scheduled simultaneously none will be scheduled - this is why it is best practice to start your VMs with a single vcpu - it is easier to schedule one cpu over 2 or 4 -

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

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

RParker thanks for the prompt reply.

So does that mean if I set a CPU share on the VMs eg. Low/Normal/High then the ESX will time slice the VMs based on this priority.

Additionally presuming if I allocated the VMs by CPU only without any reservations or limits when it does the time slicing if I have a 2CPU VM it will hold the 2Cores on the physical CPU for a given amount of time, then release it and another VM will get a time slice of a CPU, is that correct?

But what if I put limts/reservations on the VM how does that affect the time slicing of the CPU time to the VMs.

Lastly when I look at the summary for a VM I see the amount of CPU used how does that equate, if I've allocated 2 CPUs (physical server eg. Quad Core 2.933GHz (4*2.933GHz)) 6000GHz but its only using 2000Ghz(not heavily loaded VM), does that mean when the VM is given its slice of the CPU time it only actually utilizes eg. 2000GHz of the CPU processing power avaible on the CPU' s (2 * 2.933GHz, approx 6000GHz).

Thanks

0 Kudos
weinstein5
Immortal
Immortal
Jump to solution

Shares only come into play when there is contention for cpu resources - so as long as the VMs are getting the resources they need shares will have no impact on how cpu rime is delivered to the VM

Limits will cap the consumption of cycles by the VM while reservations will insure the vm will always maintain a certain amount of resources for the VM if the host is running out of resources both of these metrics should not have an impact on the time slice

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

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

how does ESX actually go about sharing the Quad Core CPU among the VMs assuming all the VMs are CPU intensive, does it allocate each VM a specific time slice or?

This is done via the hypervisor, it handles the load balance, which as Weinstein said giving VM's multiple CPU is a bad idea, you are causing more overhead for the vmkernel / hypervisor to manage, which increase ESX load, which takes away CPU from other VM's, which causes performance issues on every VM.

Additionally presuming if I allocated the VMs by CPU only without any reservations or limits when it does the time slicing if I have a 2CPU VM it will hold the 2Cores on the physical CPU for a given amount of time, then release it and another VM will get a time slice of a CPU, is that correct?

This is all done at billions of times per second. It's not any different than services / processes running on your computer right now. If you have dual core, how does Windows manage those processes? Same principle for ESX, it figures out which CPU is free (or relatively less load) and allows that VM / vCPU to run for that given time slice on that CPU, and it cycles among the VM's on the host. Both vCPU for a VM are not scheduled on the same physical core, they are kept separate, which as Weinstein explained, means that if you don't have enough free CPU resource your VM waits until it has the resource to run.

But what if I put limts/reservations on the VM how does that affect the time slicing of the CPU time to the VMs.

Reservations just means at the time you run a VM it has guaranteed resource, setting priority only affects the running VM's when the ESX server is busy. If it's not working very hard ALL the VMs are time sliced equally, when it get's above 90% utlized, then it will be forced to decide which VM's get the resource, which is when your share / priority come in.

Lastly when I look at the summary for a VM I see the amount of CPU used how does that equate, if I've allocated 2 CPUs (physical server eg. Quad Core 2.933GHz (4*2.933GHz)) 6000GHz but its only using 2000Ghz(not heavily loaded VM), does that mean when the VM is given its slice of the CPU time it only actually utilizes eg. 2000GHz of the CPU processing power avaible on the CPU' s (2 * 2.933GHz, approx 6000GHz).

Yes the stats are from the host side, it's giving you the perspective of what impact it has for host resources to give a VM its allocation of CPU cycles. So if it's running 2000ghz out of a possible 6000, that's less than a third. You should size your VM's according to overall performance needs NOT peak. so if you have an app that runs for like an hour a day and it may use up that CPU, the other 23 hours its idle, not a good use of resource. Give it only 1 CPU. You should only give VM that consistently use CPU for more than 80% of the time, but then those are probably not good candidates for Virtual anyway, so it's a self fulfilling prophecy.

0 Kudos
zenomorph
Contributor
Contributor
Jump to solution

Guys many thanks for your valuable answers they have clarifed my queiries.

Cheers......... :smileymischief:

0 Kudos
Muthuganesh
Contributor
Contributor
Jump to solution

Well, i can understand the CPU share with in a ESX host. But how does it work across hosts. In a cluster, it is possible that i can reserve CPU capacity beyond my host system capacity, right ?

If i need more CPU power than the current system, how does the CPU shares are allocated. Is the VM1 applications are run in both ESX1 & ESX2 CPU's.

Thank you,

Leo

0 Kudos
weinstein5
Immortal
Immortal
Jump to solution

No it is not possible - a VM can only run on a single host at a time -

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

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
0 Kudos