Modify CPU hyper-threading settings

更新时间:
复制 MD 格式

To improve instance performance, Alibaba Cloud enables hyper-threading by default for most instance types. This feature divides each physical core into two logical cores. However, for memory-intensive workloads or those that require high single-core performance, disabling hyper-threading can improve performance and reduce software license costs.

Use cases

By default, Alibaba Cloud enables hyper-threading on most instance types to enhance multi-threaded performance. However, for some specific workloads, disabling hyper-threading can improve overall performance or help optimize costs. The following are typical scenarios where you might consider disabling hyper-threading.

  • Improve performance for memory-intensive workloads

    For memory-intensive workloads, such as caching services, you may not require a high number of concurrent threads. In these cases, you can disable hyper-threading to optimize the compute-to-memory ratio and improve service performance.

  • Improve performance for high single-core workloads

    For workloads that require high single-core performance, disabling hyper-threading can reduce the performance overhead caused by thread contention and context switching.

  • Reduce software license costs

    Reducing the number of active CPU cores or disabling hyper-threading to lower the physical or logical core count effectively reduces software license costs.

Billing

Changing CPU options affects only the number of enabled cores or the hyper-threading setting, not the total number of vCPUs defined by the instance type. Therefore, the fee for the instance type remains the same.

Limitations

  • For some instance families, you can configure CPU options only by using an API, CLI, or SDK.

  • Only some instance types support CPU options for adjusting the number of enabled CPU cores and the hyper-threading settings. The supported parameter values vary by instance type.

    Note

    Click the instance family links below to view the supported values for the physical core count and the number of threads per core for each instance type.

Procedure

You can specify CPU options when you create an instance or modify them for an existing instance.

Configure CPU options at instance creation

You can adjust the number of enabled CPU cores and the hyper-threading settings when you create an instance. The procedure is as follows:

Console

When you create an instance by using the Custom Launch option, you can specify the number of enabled physical cores and configure hyper-threading in the Advanced Settings > CPU Options section.

  • Threads per vCPU: Controls whether hyper-threading is enabled. Only specific values are allowed. A value of 1 disables hyper-threading.

  • vCPUs: Controls the number of enabled physical cores. Only specific values are allowed.

image

API

When you call the RunInstances API operation to create and start an instance, you can specify the number of enabled physical cores and configure hyper-threading by using the following parameters:

Parameter

Type

Description

CpuOptions.Core

integer

The number of enabled physical cores. This parameter is supported only by specific instance types and requires a supported value. For details, see Limitations.

CpuOptions.ThreadsPerCore

integer

The number of threads per core. A value of 1 disables hyper-threading. This parameter is supported only by specific instance types and requires a supported value. For details, see Limitations.

CLI

You can specify the core count (CpuOptions.Core) and hyper-threading configuration (CpuOptions.ThreadsPerCore) when you use the CLI to call the RunInstances operation to create and start an instance. The following is an example command:

This command: Creates an ecs.g7.8xlarge instance (which has 16 physical CPU cores), configuring it to use 10 physical cores (CpuOptions.Core=10) and disabling hyper-threading (CpuOptions.ThreadsPerCore=1).
aliyun ecs RunInstances --RegionId cn-hangzhou \
--CpuOptions.Core 10 \
--CpuOptions.ThreadsPerCore 1 \
--ImageId aliyun_3_x64_20G_alibase_20250117.vhd \
--InstanceType ecs.g7.8xlarge \
--SecurityGroupId sg-bp1****** \
--VSwitchId vsw-bp1****** \
--SystemDisk.Category cloud_essd \
--Amount 1

Key parameter descriptions:

  • CpuOptions.Core: The number of enabled physical cores. This parameter is supported only by specific instance types and requires a supported value. For details, see Limitations.

  • CpuOptions.ThreadsPerCore: The number of threads per core. A value of 1 disables hyper-threading. This parameter is supported only by specific instance types and requires a supported value. For details, see Limitations.

Modify CPU options for an existing instance

To adjust the core count and hyper-threading settings for an existing instance, you must stop the instance before you can modify its CPU options. The procedure is as follows:

Console

Follow these steps to change the CPU options for an existing instance in the console.

  1. Find and stop the instance you want to modify.

    1. Go to ECS console - Instances.

    2. In the upper-left corner of the page, select a region and resource group.地域

    3. Find the target instance. In the Actions column, click Stop. Follow the on-screen prompts.

image

  1. Modify the CPU options.

    1. In the Actions column, click image > Change CPU Options.

    2. In the Change CPU Options dialog box, modify the settings.

      • Total core count: The number of enabled CPU cores. Only specific values are allowed.

      • Threads per Core: Controls whether hyper-threading is enabled. Only specific values are allowed. A value of 1 disables hyper-threading.

    3. After you configure the settings, click OK.

image

  1. Restart the ECS instance.

    In the Actions column, click Start. Wait for the instance to start.

API

To specify the number of enabled physical cores and configure hyper-threading, use the following API call sequence.

  1. Call the StopInstance operation to stop the instance.

  2. Call the ModifyInstanceAttribute operation to change the CPU options. The following parameters are relevant:

    Parameter

    Type

    Description

    CpuOptions.Core

    integer

    The number of enabled physical cores. This parameter is supported only by specific instance types and requires a supported value. For details, see Limitations.

    CpuOptions.ThreadsPerCore

    integer

    The number of threads per core. A value of 1 disables hyper-threading. This parameter is supported only by specific instance types and requires a supported value. For details, see Limitations.

  3. Call the StartInstance operation to restart the instance and apply the changes.

CLI

To specify the number of enabled physical cores and configure hyper-threading, use the following CLI call sequence.

  1. Call the StopInstance operation to stop the instance.

    aliyun ecs StopInstance --region cn-hangzhou \
    --InstanceId i-bp1******
  2. Call the ModifyInstanceAttribute operation to change the CPU options.

    This command: Modifies the CPU options for instance i-bp1******, enabling 10 physical cores (CpuOptions.Core=10) and disabling hyper-threading (CpuOptions.ThreadsPerCore=1).
    aliyun ecs ModifyInstanceAttribute --region cn-hangzhou \
    --InstanceId i-bp1****** \
    --CpuOptions.Core 10 \
    --CpuOptions.ThreadsPerCore 1

    Key parameter descriptions:

    • CpuOptions.Core: The number of enabled physical cores. This parameter is supported only by specific instance types and requires a supported value. For details, see Limitations.

    • CpuOptions.ThreadsPerCore: The number of threads per core. A value of 1 disables hyper-threading. This parameter is supported only by specific instance types and requires a supported value. For details, see Limitations.

  3. Call the StartInstance operation to restart the ECS instance.

    aliyun ecs StartInstance --region cn-hangzhou \
    --InstanceId i-bp1******

Related topics

  • After modifying the CPU options, perform system stability tests to ensure that the system runs as expected. Run load tests or application-specific tests to observe the system's response and performance.

  • After an ECS instance is created, you can monitor its performance metrics and resource utilization, and optimize it as needed. For more information, see View instance monitoring information.

  • In scenarios such as virtualization, multi-threaded programming, and high-performance computing, you can view and modify the CPU topology (CpuOptions.TopologyType) to improve ECS instance performance, enhance parallelism, and optimize resource allocation.