The accepted answer states 'a vCPU is simply a hyperthread of a single core'.
This isn't always true.
It's more accurate to state that a vCPU is a virtualized abstraction of a physical CPU core or thread, depending on the instance type and CPU type.
Fargate vCPUs are equal to EC2 vCPUs, as Fargate uses ECS & ECS uses EC2 instances.
Let's try to define a vCPU.
The official documentation is conflicting:
Each vCPU on Graviton-based Amazon EC2 instances is a core of AWS Graviton processor.
Each vCPU on non-Graviton-based Amazon EC2 instances is a thread of x86-based processor, except for T2 instances and m3.medium.
Each vCPU on non-Graviton-based Amazon EC2 instances is a thread of x86-based processor.
Each vCPU is a thread of either an Intel Xeon core or an AMD EPYC core, except for T2 and m3.medium.
Each vCPU is a thread of a CPU core, except for T2 instances and 64-bit ARM platforms such as instances powered by AWS Graviton2 processors and Apple Silicon Mac instances.
And not just in one one place...
Each thread is represented as a virtual CPU (vCPU) on the instance.
But multiple:
Each vCPU is a thread of either an Intel Xeon core or an AMD EPYC core, except for T2 and T4g instances.
Is it a core? A thread? What exactly is a vCPU in the context of exceptions?
Why are only T2
and T4g
instances exceptions? It seems logical that T3
and T3a
should also be exceptions, as they are also burstable, use a credit system, and all have a baseline performance below 100% of 1 core (with the exception of t2.2xlarge
). Since the vCPU for burstable instances represents the maximum CPU performance for the instance, not the steady CPU performance, it's understandable why AWS does not equate vCPU to a 'core' or a 'thread' in this case.
However, why are Apple Silicon Mac instances an exception? Both EC2 M1 and EC2 M2 instances have 8 cores, with a vCPU count of 8. The EC2 M2 Pro has 12 cores, with a vCPU count of 12. Is this because AWS differentiates between Apple's high-performance cores (P cores) and high-efficiency cores (E cores)? Why hasn't this been clarified?
Again, why is only m3.medium
mentioned? What about m4
or m5
? This is something I can't figure out.
Ultimately, the documentation implies that vCPU equals thread with very vague wording:
Each thread is represented as a virtual CPU (vCPU) on the instance.
I think it should be something along the lines of:
A vCPU is a virtualized abstraction of a physical CPU core or thread, depending on the instance type and CPU type.
It is the core count multiplied by the number of threads.
While a vCPU is not always strictly a thread, the maximum CPU thread count is equal to the vCPU count of an instance, with the vCPU mapping to either a hyper-thread of a physical core or to the physical core itself.
If I allocate 4 vCPUs to my task does that mean that my single-threaded app running on a container in this task will be able to fully use all this vCPUs as they are essentially only a portion of time of the processor's core that I can use?
No, a single-threaded app can only use 1 thread at a time.
Let's say, I assigned 4vCPUs to my task, but on a technical level I assigned 4vCPUs to a physical core that can freely process one thread (or even more with hyperthreading). Is my logic correct for the Fargate case?
Currently, it is impossible to achieve 4 vCPUs with 1 core, as that would mean 4 threads per core. No instance type or CPU configuration provided by AWS today enables this.
Even if it was, a single-threaded application can only use 1 thread.