The CPU options of an ECS instance include the number of 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 and 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 one 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 CPU cores CpuOptions.Core Determines the number of physical CPU cores. You can increase the number of CPU cores for memory optimized instance types to improve the performance of instances. For more information, see Valid values for the number of CPU cores and 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 CPU cores × Number of threads per core.

In most cases, an ECS instance type provides sufficient performance for your workloads. You can customize this parameter for the following scenarios:
  • High-performance computing (HPC) workloads. In these scenarios, you can choose to disable Hyper-Threading.
  • Memory-intensive business scenarios. You can disable Hyper-Threading to reduce the number of cores and increase the CPU-to-memory ratio of each core. This way, your costs for software licensing which is charged based on the number of cores can be reduced as the number of chargeable items is less.

Billing

Customizing CPU options does not incur additional charges.

Limits

  • Only the g6, r6, c6, hfc6, hfg6, and hfr6 instance families support custom CPU options. For information about the valid values of CPU options, see the Valid values for the number of CPU cores and number of threads per core section in this topic.
  • CPU options can only be customized 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 CPU cores cannot be customized.

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, 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 4 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 2 vCPUs.

View CPU options

You can call the DescribeInstances operation to view the CPU options of an ECS instance. If an SDK is used, 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 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 CPU cores and number of threads per core

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

Instance type Default value for the number of vCPUs Valid values for the number of 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
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
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
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
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
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