Azure vCPUs and Hyper-threading

First of all, what the heck is Hyper-threading? Well, in a nutshell Hyper-threading is a technology found on some Intel chips (AMD have their own equivalent technology) to improve multi-tasking by running tasks in parallel on the CPU.

For most compute workloads multi-tasking is very common so Hyper-threading is usually very helpful and allows your processors to perform more tasks simultaneously rather than queuing them up and processing serially. This cuts down on idle CPU time and in particular works really well for things like video editing, rendering jobs and in multi-user environments.

With Hyper-threading enabled the Operating System will address each physical or virtual CPU core as two logical cores or “threads”. For example if a particular Virtual Machine has 2 virtual cores assigned this will be represented as 4 logical cores – a 2:1 ratio of logical cores to virtual cores if you will.

In general terms (though in reality it depends on what your workload is), if you want more performance then you should go with more physical or virtual cores first and foremost. You can then makes these cores work harder by enabling Hyper-threading. To put into context a 4-core/4 thread Virtual Machine with no Hyper-threading is going to be more powerful than a 2-core/4 thread Virtual Machine with Hyper-threading. However a 4-core/8 thread Virtual Machine with Hyper-threading is better again as it can perform more tasks simultaneously on those 4 CPU cores.

When sizing Virtual Machines in Azure one of the key decisions for sizing will be the number of vCPUs available but what is a vCPU in Azure? This is where you need to read up on the documented Virtual Machine descriptions. Every Virtual Machine family is different and this includes the types of processors used. Most have Intel processors of varying types and sizes, some now have AMD processors and importantly some offer Hyper-threading and some don’t.

In Azure, where you see the number of vCPU cores listed against a particular Virtual Machine size this represents the number of logical cores. So for Hyper-threading enabled Virtual Machines such as the D_v3 and E_v3 series a size listed with 8 vCPUs such as the D8_v3 size has got 8 logical CPU cores/threads but actually only has 4 virtual CPU cores. Compare this to the D4_v2 size which is also listed as having 8 vCPUs but here there is no Hyper-threading so there are a full 8 CPU cores with 8 logical cores/threads. So although both sizes are listed as having 8 vCPUs in fact the D4_v2 size has double the number of CPU cores than the D8_v3 size. Surprise!!!

I know from speaking to a lot of customers that many people are not aware of this. Quite often I see customers going with D_v3 sizes thinking they are getting 4 CPU core Virtual Machines for a cheaper price than the D_v2 equivalent vCPU option. Usually once their solution is deployed they find the performance isn’t quite what they expected due to the fact they are running on fewer virtual cores than they realised.

The key point here is that Hyper-threading is usually very useful and can be a great way of getting your processors to do more work at once but make sure you understand how many virtual cores you are getting on your Virtual Machines. You don’t want to under spec and then have to go back to your customer and explain your mistake.

You will find a full list of Azure Virtual Machine families and their vCPU to logical core ratios here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.