VMware Cloud Community
bgushue
Contributor
Contributor

Hyperthreading and CPU Affinity

I'd like to understand something. Given two scenarios:

1. A VM that hogs CPU resources and you want to isolate that VM so that it only uses one physical CPU, but you want other VMs to have access to that CPU.

2. A mission critical VM that you want to ensure has sole access to one physical CPU.

If I understand correctly, I can address scenario 1 with CPU affinity. Assigning the VM only one CPU will restrict it to using that CPU but will allow other VMs to have access to that CPU. Is this correct and is this the only way?

I can address scenario 2 with the hyperthreading option "None" which will allow for exclusive use of the processor core when the vCPU is scheduled to it. This will allow other VMs to use the CPU, but not when the mission critical server requires it. Is this true? Also, this assumes hyperthreading is enabled. What if it isn't? Is the only way to achieve this to assign CPU affinity to one processor for that VM and configure all other VMs to use any CPUs except the first one?

Thank you.

0 Kudos
10 Replies
ianmellor
Enthusiast
Enthusiast

Hi,

Are these VM's on a stand alone host or a DRS cluster. It is not good to assign CPU Affinity when your VM's are in a DRS Cluster, because CPU admission control does not consider affinity, a VM with manual affinity settings might not always receive it full reservation.

Another way would be to assign more resource shares to your mission critical VM's.

oreeh
Immortal
Immortal

If you want to achieve your scenarios use shares and revervations instead.

Here's an excellent thread (especially user puneetz) regarding this http://www.vmware.com/community/thread.jspa?threadID=73411

If you use CPU affinity you break vMotion!

bgushue
Contributor
Contributor

Thank you everybody!

It's a hypothetical question at this point. Our implementation of ESX is small at the moment (one box used for QA, although we have over 50 vms on it). We're thinking about the future and your points are appreciated - good points about DRS Clustering and Vmotion!

I read the thread and the page in the Resource Guide - thanks for pointing these out.

So it would seem sticking with reservations, shares and limits would be the proper course of action.

I guess the next question would be when would you ever use cpu affinity and/hyperthreading?

0 Kudos
oreeh
Immortal
Immortal

I guess the next question would be when would you ever use cpu affinity and/hyperthreading?

In an ESX cluster - never!

0 Kudos
bgushue
Contributor
Contributor

Understood!

We've mostly been talking about CPU affinity but is all the same true for hyperthreading?

Sorry if this is redundant, but I don't want to confuse the two when I explain all this to those who need to know.

Thank you.

0 Kudos
RParker
Immortal
Immortal

As Oreeh has suggested, CPU reservation is your best bet. CPU affinity wouldn't give you what you think it would.

Let ESX manage your environment, just apply proirities as needed.. ESX does it quite well, you just have to indicate which VM's are more important, and ESX will go from there.

0 Kudos
oreeh
Immortal
Immortal

The same is true for hyperthreading.

As RParker already mentioned: Let ESX do the job - it was designed for this.

0 Kudos
bgushue
Contributor
Contributor

I like those answers. Thank you all very much!

0 Kudos
RParker
Immortal
Immortal

Also if you have new architecture, hypthreading doesn't even exist. It was a step up measure for Intel to eek out that 10% of idle CPU, but Dual Core/Quad Core solves this problem, and hyperthreading is a thing of the past.

The core brothers are much faster than their older counterparts anyway, so if you are serious about ESX, and you still have hyperthreaded hardware, I would highly recommend you upgrade to core team!

0 Kudos
kenzo36
Contributor
Contributor

Hey guys, could someone answer a follow up to this thread... I need to P2V a windows box that has Hyperthreading and has a hyperthreading dependant application. It seems that the performance of the application decreases after the migration...

The VM is assigned only one vCPU, do I need to assign 2 vCPU's to account for the hyperthreading?

Thx.

0 Kudos