The CPU options of an ECS instance include the number of physical CPU cores and the number of threads per core. For some ECS instance types, you can customize the CPU options of an instance when you create the instance by calling the RunInstances operation.

CPU and vCPU

CPUs are central processing units. A single CPU can contain several physical cores. The Hyper-Threading (HT) technology creates two virtual processing cores for each physical core present in a CPU. Virtual CPUs (vCPUs) are virtual processing cores of ECS instances.

Alibaba Cloud ECS supports multithreading based on the Intel ® Hyper-Threading technology. With the Hyper-Threading technology, two threads can run concurrently on a single physical core. Each thread can be considered as a vCPU. For more information, visit Intel® Hyper-Threading Technology.

The following table describes the CPU options for ECS instances.

CPU option API parameter Description Scenario Applicable instance type
Number of physical CPU cores CpuOptions.Core Determines the number of physical CPU cores enabled. When you reduce the number of physical CPU cores enabled and increase the CPU-to-memory ratio, the number of chargeable items is reduced. This can reduce your costs for software licensing. For more information, see Valid values for the number of physical CPU cores and the number of threads per core.
Number of threads per core CpuOptions.ThreadsPerCore Determines whether to enable Hyper-Threading on the CPU.

Number of vCPUs = Number of physical CPU cores × Number of threads per core.

In most cases, an ECS instance type provides sufficient performance for your workloads. You can choose to disable Hyper-Threading in the following scenarios:
  • High-performance computing (HPC) scenarios. In these scenarios, you can improve performance by disabling Hyper-Threading.
  • Memory-intensive business scenarios. You can disable Hyper-Threading to reduce the number of vCPUs and increase the CPU-to-memory ratio. This will decrease the number of chargeable items and reduce software licensing costs.

Billing

Customizing CPU options does not incur additional charges.

Limits

  • Only the g6e, c6e, r6e, g6, c6, r6, hfg6, hfc6, and hfr6 instance families support custom CPU options. For information about valid values of CPU options, see the Valid values for the number of physical CPU cores and the number of threads per core section in this topic.
  • CPU options can be customized only when you create an instance and cannot be modified after the instance is created.
  • When you change the instance type of an ECS instance, its CPU options are changed to the default CPU options for the new instance type.
  • The number of physical cores available in an ECS instance is determined by the instance type of the instance. You can specify the number of physical CPU cores within the valid values.

Enable or disable Hyper-Threading

You can call the RunInstances operation to customize the CPU options of an ECS instance. If an SDK is used, you must upgrade it to the latest version.

  • By default, Hyper-Threading is enabled on ECS instances. You can enable Hyper-Threading in Alibaba Cloud CLI, as shown in the following sample request:
    aliyun ecs RunInstances --RegionId cn-hangzhou --CpuOptions.Core 2 --CpuOptions.ThreadsPerCore 2 --ImageId ubuntu_18_04_64_20G_alibase_20190624.vhd --InstanceType ecs.g6.6xlarge --SecurityGroupId sg-bp67acfmxazb4ph*** --VSwitchId vsw-bp1s5fnvk4gn2tws03*** --Amount 1 --SystemDisk.AutoSnapshotPolicyId sp-bp67acfmxazb4ph***
  • To disable Hyper-Threading, set the CpuOptions.ThreadsPerCore parameter to 1 in Alibaba Cloud CLI, as shown in the following sample request:
    aliyun ecs RunInstances --RegionId cn-hangzhou --CpuOptions.Core 2 --CpuOptions.ThreadsPerCore 1 --ImageId ubuntu_18_04_64_20G_alibase_20190624.vhd --InstanceType ecs.g6.6xlarge --SecurityGroupId sg-bp67acfmxazb4ph*** --VSwitchId vsw-bp1s5fnvk4gn2tws03*** --Amount 1 --SystemDisk.AutoSnapshotPolicyId sp-bp67acfmxazb4ph***
In this example, the ecs.g6.xlarge instance type provides two physical CPU cores by default.
  • Enable Hyper-Threading: You can enable Hyper-Threading by setting the number of threads per core to 2. The instance type will have four vCPUs, which is the product of the number of CPU cores and the number of threads per core. Hyper-Threading is enabled by default for this instance type.
  • Disable Hyper-Threading: You can disable Hyper-Threading by setting the number of threads per core to 1. The instance type will have only two vCPUs.

View CPU options

You can call the DescribeInstances operation to view the CPU options of an ECS instance. If an SDK is used, you must upgrade it to the latest version.

  • Sample request in Alibaba Cloud CLI:
    aliyun ecs DescribeInstances --InstanceIds '["i-bp19rxmzeocge2z57***"]' --output cols=CpuOptions rows=Instances.Instance[]
    Sample response:
    CpuOptions
    ----------
    map[CoreCount:1 ThreadsPerCore:2]
  • Usage example of the lscpu Shell command:
    shell@ecshost:~$ lscpu
    Architecture:        x86_64
    Byte Order:          Little Endian
    CPU(s):              1   # Number of physical CPU cores
    On-line CPU(s) list: 0
    Thread(s) per core:  2   # Number of threads per core
    Core(s) per socket:  1
    Socket(s):           1
    Vendor ID:           GenuineIntel
    CPU family:          6
    Model:               85
    Model name:          Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz
    ......

Valid values for the number of physical CPU cores and the number of threads per core

The following tables list the default values and valid values for the number of physical CPU cores (CpuOptions.Core) and the number of threads per core (CpuOptions.ThreadsPerCore). Instance types not listed in the tables do not support custom CPU options.

Table 1. Valid values for the number of physical CPU cores and the number of threads per core of the g6e instance family
Instance type Default value for the number of vCPUs Valid values for the number of physical CPU cores Default value for the number of threads per core Valid values for the number of threads per core
ecs.g6e.large 2 1 2 1, 2
ecs.g6e.xlarge 4 2 2 1, 2
ecs.g6e.2xlarge 8 2, 4 2 1, 2
ecs.g6e.4xlarge 16 2, 4, 6, 8 2 1, 2
ecs.g6e.8xlarge 32 2, 4, 6, 8, 10, 12, 14, 16 2 1, 2
ecs.g6e.13xlarge 52 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26 2 1, 2
ecs.g6e.26xlarge 104 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52 2 1, 2
Table 2. Valid values for the number of physical CPU cores and the number of threads per core of the c6e instance family
Instance type Default value for the number of vCPUs Valid values for the number of physical CPU cores Default value for the number of threads per core Valid values for the number of threads per core
ecs.c6e.large 2 1 2 1, 2
ecs.c6e.xlarge 4 2 2 1, 2
ecs.c6e.2xlarge 8 2, 4 2 1, 2
ecs.c6e.4xlarge 16 2, 4, 6, 8 2 1, 2
ecs.c6e.8xlarge 32 2, 4, 6, 8, 10, 12, 14, 16 2 1, 2
ecs.c6e.13xlarge 52 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26 2 1, 2
ecs.c6e.26xlarge 104 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52 2 1, 2
Table 3. Valid values for the number of physical CPU cores and the number of threads per core of the r6e instance family
Instance type Default value for the number of vCPUs Valid values for the number of physical CPU cores Default value for the number of threads per core Valid values for the number of threads per core
ecs.r6e.large 2 1 2 1, 2
ecs.r6e.xlarge 4 2 2 1, 2
ecs.r6e.2xlarge 8 2, 4 2 1, 2
ecs.r6e.4xlarge 16 2, 4, 6, 8 2 1, 2
ecs.r6e.8xlarge 32 2, 4, 6, 8, 10, 12, 14, 16 2 1, 2
ecs.r6e.13xlarge 52 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26 2 1, 2
ecs.r6e.26xlarge 104 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52 2 1, 2
Table 4. Valid values for the number of physical CPU cores and the number of threads per core of the g6 instance family
Instance type Default value for the number of vCPUs Valid values for the number of physical CPU cores Default value for the number of threads per core Valid values for the number of threads per core
ecs.g6.large 2 1 2 1, 2
ecs.g6.xlarge 4 2 2 1, 2
ecs.g6.2xlarge 8 2, 4 2 1, 2
ecs.g6.3xlarge 12 2, 4, 6 2 1, 2
ecs.g6.4xlarge 16 2, 4, 6, 8 2 1, 2
ecs.g6.6xlarge 24 2, 4, 6, 8, 10, 12 2 1, 2
ecs.g6.8xlarge 32 2, 4, 6, 8, 10, 12, 14, 16 2 1, 2
ecs.g6.13xlarge 52 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26 2 1, 2
ecs.g6.26xlarge 104 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52 2 1, 2
Table 5. Valid values for the number of physical CPU cores and the number of threads per core of the c6 instance family
Instance type Default value for the number of vCPUs Valid values for the number of physical CPU cores Default value for the number of threads per core Valid values for the number of threads per core
ecs.c6.large 2 1 2 1, 2
ecs.c6.xlarge 4 2 2 1, 2
ecs.c6.2xlarge 8 2, 4 2 1, 2
ecs.c6.3xlarge 12 2, 4, 6 2 1, 2
ecs.c6.4xlarge 16 2, 4, 6, 8 2 1, 2
ecs.c6.6xlarge 24 2, 4, 6, 8, 10, 12 2 1, 2
ecs.c6.8xlarge 32 2, 4, 6, 8, 10, 12, 14, 16 2 1, 2
ecs.c6.13xlarge 52 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26 2 1, 2
ecs.c6.26xlarge 104 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52 2 1, 2
Table 6. Valid values for the number of physical CPU cores and the number of threads per core of the r6 instance family
Instance type Default value for the number of vCPUs Valid values for the number of physical CPU cores Default value for the number of threads per core Valid values for the number of threads per core
ecs.r6.large 2 1 2 1, 2
ecs.r6.xlarge 4 2 2 1, 2
ecs.r6.2xlarge 8 2, 4 2 1, 2
ecs.r6.3xlarge 12 2, 4, 6 2 1, 2
ecs.r6.4xlarge 16 2, 4, 6, 8 2 1, 2
ecs.r6.6xlarge 24 2, 4, 6, 8, 10, 12 2 1, 2
ecs.r6.8xlarge 32 2, 4, 6, 8, 10, 12, 14, 16 2 1, 2
ecs.r6.13xlarge 52 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26 2 1, 2
ecs.r6.26xlarge 104 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52 2 1, 2
Table 7. Valid values for the number of physical CPU cores and the number of threads per core of the hfg6 instance family
Instance type Default value for the number of vCPUs Valid values for the number of physical CPU cores Default value for the number of threads per core Valid values for the number of threads per core
ecs.hfg6.large 2 1 2 1, 2
ecs.hfg6.xlarge 4 2 2 1, 2
ecs.hfg6.2xlarge 8 2, 4 2 1, 2
ecs.hfg6.3xlarge 12 2, 4, 6 2 1, 2
ecs.hfg6.4xlarge 16 2, 4, 6, 8 2 1, 2
ecs.hfg6.6xlarge 24 2, 4, 6, 8, 10, 12 2 1, 2
ecs.hfg6.8xlarge 32 2, 4, 6, 8, 10, 12, 14, 16 2 1, 2
ecs.hfg6.10xlarge 40 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 2 1, 2
ecs.hfg6.16xlarge 64 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32 2 1, 2
ecs.hfg6.20xlarge 80 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40 2 1, 2
Table 8. Valid values for the number of physical CPU cores and the number of threads per core of the hfc6 instance family
Instance type Default value for the number of vCPUs Valid values for the number of physical CPU cores Default value for the number of threads per core Valid values for the number of threads per core
ecs.hfc6.large 2 1 2 1, 2
ecs.hfc6.xlarge 4 2 2 1, 2
ecs.hfc6.2xlarge 8 2, 4 2 1, 2
ecs.hfc6.3xlarge 12 2, 4, 6 2 1, 2
ecs.hfc6.4xlarge 16 2, 4, 6, 8 2 1, 2
ecs.hfc6.6xlarge 24 2, 4, 6, 8, 10, 12 2 1, 2
ecs.hfc6.8xlarge 32 2, 4, 6, 8, 10, 12, 14, 16 2 1, 2
ecs.hfc6.10xlarge 40 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 2 1, 2
ecs.hfc6.16xlarge 64 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32 2 1, 2
ecs.hfc6.20xlarge 80 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40 2 1, 2
Table 9. Valid values for the number of physical CPU cores and the number of threads per core of the hfr6 instance family
Instance type Default value for the number of vCPUs Valid values for the number of physical CPU cores Default value for the number of threads per core Valid values for the number of threads per core
ecs.hfr6.large 2 1 2 1, 2
ecs.hfr6.xlarge 4 2 2 1, 2
ecs.hfr6.2xlarge 8 2, 4 2 1, 2
ecs.hfr6.3xlarge 12 2, 4, 6 2 1, 2
ecs.hfr6.4xlarge 16 2, 4, 6, 8 2 1, 2
ecs.hfr6.6xlarge 24 2, 4, 6, 8, 10, 12 2 1, 2
ecs.hfr6.8xlarge 32 2, 4, 6, 8, 10, 12, 14, 16 2 1, 2
ecs.hfr6.10xlarge 40 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 2 1, 2
ecs.hfr6.16xlarge 64 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32 2 1, 2
ecs.hfr6.20xlarge 80 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40 2 1, 2