I'm trying to understand meaning of vCPU and CPU units and connection of these concepts to physical CPU.
I have ECS cluster with one cluster instance, which is m5ad.large EC2 instance.
Here is output of lscpu
command on this instance:
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 2
On-line CPU(s) list: 0,1
Thread(s) per core: 2
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: AuthenticAMD
CPU family: 23
Model: 1
Model name: AMD EPYC 7571
Stepping: 2
CPU MHz: 2892.092
BogoMIPS: 4399.83
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 64K
L2 cache: 512K
L3 cache: 8192K
NUMA node0 CPU(s): 0,1
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch topoext vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 clzero xsaveerptr arat npt nrip_save
This instance has one processor (Socket(s): 1
), one core per socket and 2 threads per core, that's why actual number of threads is number of sockets * number of cores per socket * number of threads per core = 1 * 1 * 2 = 2
.
So, if I understand correct, this value is also a number of available vCPU, and vCPU is kernel thread.
As it said in ECS documentation, number of CPU units can be calculated as number of vCPU * 1024
. In this case, there are 2048 CPU units
My questions are what is CPU unit, why am I need to multiply on 1024 and what is physical connection between processor and CPU units?
Amazon ECS uses a standard unit of measure for CPU resources called CPU units. 1024 CPU units is the equivalent of 1 vCPU. For example, 2048 CPU units is equal to 2 vCPU. Note: When defining task definitions, you can also use 1 vCPU instead of 1024.
An AWS vCPU is a single hyperthread of a two-thread Intel Xeon core for M5, M4, C5, C4, R4, and R4 instances. A simple way to think about this is that an AWS vCPU is equal to half a physical core.
This instance has one processor ( Socket(s): 1 ), one core per socket and 2 threads per core, that's why actual number of threads is number of sockets * number of cores per socket * number of threads per core = 1 * 1 * 2 = 2 .
A CPU share defines how much of the overall CPU your container can have access to, as you add more containers this becomes a ratio of division between each container. Each of your containers in your case will get 2, if there are 4 containers this is a ratio of 0.25 of the available CPU per each one.
When running containers, CPU allocation is typically done using CPU units as described in the ECS documentation:
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size
1024 CPU units corresponds to 1 vCPU.
In the task definition you can specify the CPU allocation using either CPU units (e.g. 1024) or as a vCPU string (e.g. 1 vCPU).
You don't have to convert to CPU units, ECS can do that for you. If you prefer to think of CPU allocation using vCPUs, that's fully supported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With