Stay organized with collections Save and categorize content based on your preferences.
Linux Windows
Simultaneous multithreading (SMT), which is known on Intel processors as Hyper-Threading Technology (HTT), lets a CPU core run as two hardware multithreads. On Compute Engine, each virtual CPU (vCPU) is implemented as a single hardware multithread, and two vCPUs share each physical CPU core by default.
Compute Engine lets you manually set the value for the number of threads per core. For example, workloads with the following concerns might benefit from disabling SMT (setting the number of threads per core to 1):
Performance: Reducing the number of threads that run on each physical CPU core can help improve the performance of workloads that are highly-parallel or that perform floating point calculations.
Security: If a VM runs untrusted code, reducing the number of threads per core can help mitigate CPU vulnerabilities such as Microarchitectural Data Sampling.
Licensing: Some licensing agreements have requirements related to the number of vCPUs that you consume. Reducing the number of threads per core from 2 to 1 might reduce your licensing costs. For more information, consult your licensing agreement.
For many general computing tasks or tasks that require lots of I/O, SMT can increase application throughput significantly. For compute-bound jobs in which both virtual cores are compute-bound, SMT can hinder overall application performance and can add unpredictable variance to jobs. In this case, turning off SMT allows more predictable performance and can decrease job times.
Important: Disabling SMT changes the way cores are counted and may increase the cost per core. Although cost per core is a common metric for on-premises hardware, a more appropriate metric for the cloud is cost per workload, or cost per job. For compute-bound jobs, you pay for what you use. Turning off SMT can reduce the overall runtime, which can reduce the overall cost of the job. We recommend that you benchmark your application and use this feature where it's beneficial. LimitationsYou cannot set the number of threads per core on VMs for the following machine types:
n1-standard-1
e2-small
.For bare metal instances, the number of hyperthreads you have access to is equivalent to the number of hyperthreads on the machine.
In the Google Cloud console, when the number of threads per core is set to 1, the CPU utilization metric can only scale up to a maximum of 50%. When the number of threads per core is set to 2, the CPU utilization metric can scale up to 100%.
You are billed for the number of vCPUs defined by a VM's machine type, not the number of threads that run on each core. For example, the n2-standard-8
machine type can run up to 8 vCPUs, which is 2 vCPUs for each of the 4 physical CPU cores. If, with the n2-standard-8
machine type, you decide to only run 1 thread per core—effectively 4 vCPUs—you are still billed for 8 vCPUs. For more information about how you are billed for VMs, see VM instance pricing.
To change the number of threads per core during VM creation, use the Google Cloud console, the gcloud CLI, or the Compute Engine API.
Permissions required for this taskTo perform this task, you must have the following permissions:
To change the number of threads per core during VM creation, use the following Google Cloud console procedure:
In the Google Cloud console, go to the Create an instance page.
In the Name field, enter a name for the VM.
Choose a Region and a Zone for the VM.
Choose a Machine family and a supported Machine type.
Click Advanced configurations to expand the section.
In vCPUs to core ratio, choose the number of threads per core.
Finish configuring other settings for the VM and click Create.
To change the number of threads per core during VM creation, use the gcloud compute instances create
command.
Before using any of the command data below, make the following replacements:
2
or 1
.Execute the following command:
Linux, macOS, or Cloud Shellgcloud compute instances create VM_NAME \ --zone=ZONE \ --machine-type=MACHINE_TYPE \ --threads-per-core=THREADS_PER_COREWindows (PowerShell)
gcloud compute instances create VM_NAME ` --zone=ZONE ` --machine-type=MACHINE_TYPE ` --threads-per-core=THREADS_PER_COREWindows (cmd.exe)
gcloud compute instances create VM_NAME ^ --zone=ZONE ^ --machine-type=MACHINE_TYPE ^ --threads-per-core=THREADS_PER_CORE
You should receive a response similar to the following:
Created [https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME]. NAME: VM_NAME ZONE: ZONE MACHINE_TYPE: MACHINE_TYPE PREEMPTIBLE: INTERNAL_IP: EXTERNAL_IP EXTERNAL_IP: INTERNAL_IP STATUS: RUNNINGREST
To change the number of threads per core during VM creation, use the instances.insert
method with the threadsPerCore
field.
Before using any of the request data, make the following replacements:
2
or 1
.HTTP method and URL:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances
Request JSON body:
{ "machineType": "projects/PROJECT_ID/zones/ZONE/machineTypes/MACHINE_TYPE", "name": "VM_NAME", "advancedMachineFeatures": { "threadsPerCore": THREADS_PER_CORE }, "disks": [ { "type": "PERSISTENT", "boot": true, "initializeParams": { "sourceImage": "projects/debian-cloud/global/images/family/debian-11" } } ], "networkInterfaces": [ { "network": "global/networks/default" } ] }
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)Save the request body in a file named request.json
, and execute the following command:
curl -X POST \PowerShell (Windows)
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances"
Save the request body in a file named request.json
, and execute the following command:
$cred = gcloud auth print-access-tokenAPIs Explorer (browser)
$headers = @{ "Authorization" = "Bearer $cred" }Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances" | Select-Object -Expand Content
Copy the request body and open the method reference page. The APIs Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Paste the request body in this tool, complete any other required fields, and click Execute.
You should receive a JSON response similar to the following:
{ "kind": "compute#operation", "id": "7334609091572405391", "name": "operation-1663806045894-5e939085735d8-7499db32-c12fcc03", "zone": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE", "operationType": "insert", "targetLink": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME", "targetId": "1226375378512516273", "status": "RUNNING", "user": "EMAIL_ADDRESS", "progress": 0, "insertTime": "2022-09-21T17:20:48.751-07:00", "startTime": "2022-09-21T17:20:48.751-07:00", "selfLink": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/operations/operation-1663806045894-5e939085735d8-7499db32-c12fcc03" }Change the number of threads per core on a VM
To change the number of threads per core on a VM, use the Google Cloud console, the gcloud CLI, or the Compute Engine API.
Permissions required for this taskTo perform this task, you must have the following permissions:
compute.instances.get
on the projectcompute.instances.update
on the projectTo change the number of threads per core on an existing VM, use the following Google Cloud console procedure:
In the Google Cloud console, go to the VM instances page.
Click the Name of the VM.
Click stop Stop to stop the VM. If there is no Stop option, click more_vert More actions > stop Stop.
Click Edit.
Click Advanced configurations to expand the section.
In the vCPUs to core ratio drop-down list, choose the number of threads per core.
Click Save.
To change the number of threads per core on an existing VM, do the following:
Export the properties of the VM by using the following gcloud compute instances export
command:
gcloud compute instances export VM_NAME \ --destination=YAML_FILE_PATH \ --zone=ZONE
Replace the following:
VM_NAME
: the name of the VM from which to export properties
YAML_FILE_PATH
: the path and filename of a YAML file in which to save the exported configuration data
ZONE
: the zone that contains the VM
In the VM configuration file that was saved in FILE_PATH, update the value for threadsPerCore
. If the value is not in the file, add the following:
advancedMachineFeatures: threadsPerCore: THREADS_PER_CORETip: To avoid getting an error such as
"ERROR: (gcloud.compute.instances.update-from-file) Cannot parse YAML: [Expected type for field value, found True (type )]"
, add quotes (' '
) around any label values of yes
or no
in the exported instance configuration file. This indicates the values are strings, not Boolean values.Update the VM with the new count of threads per core by using the following gcloud compute instances update-from-file
command:
gcloud compute instances update-from-file VM_NAME \ --source=FILE_PATH \ --most-disruptive-allowed-action=RESTART \ --zone=ZONE
Replace the following:
VM_NAME
: the name of the VM to update
FILE_PATH
: the path to the updated VM configuration file
ZONE
: the zone that contains the VM to update
To change the number of threads per core on an existing VM, use the following instances.update
method:
PUT https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME?most_disruptive_allowed_action=RESTART { ... "advanced_machine_features": { ... "threadsPerCore": "THREADS_PER_CORE" }, ... }
Replace the following:
PROJECT_ID
: the ID of the project
ZONE
: the zone that contains the VM
VM_NAME
: the name of the VM from which to export properties
THREADS_PER_CORE
: the number of threads per core
To view the number of threads per core, use the procedure that corresponds to the OS that is running on the VM.
LinuxTo view the number of threads per core on Linux-based VMs, use the following procedure:
Run the lscpu
command.
lscpu
Review the output to view the number of threads per core.
In the following sample output from an n2-standard-16
machine, the value for the number of threads per core is 1
as shown in the Thread(s) per core
line.
...
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 1
Core(s) per socket: 8
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 85
Model name: Intel(R) Xeon(R) CPU @ 2.80GHz
...
To view the number of threads per core on Windows-based VMs, use the following procedure:
Launch Powershell.
Run the following command.
Get-WmiObject -Class Win32_processor | Select-Object NumberOfCores, @{Name="Thread(s) per core";Expression={$_.NumberOfLogicalProcessors/$_.NumberOfCores}}
Review the output to view the number of threads per core.
In the following sample output from an n2-standard-16
machine, the value for the number of threads per core is 1
as shown in the Thread(s) per core
column.
NumberOfCores Thread(s) per core
------------- ------------------
8 1
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Compute Engine allows users to manually adjust the number of threads per CPU core, with each virtual CPU (vCPU) typically corresponding to a single hardware multithread, and two vCPUs sharing a physical core by default."],["Disabling simultaneous multithreading (SMT), known as Hyper-Threading Technology (HTT) on Intel processors, by setting the number of threads per core to 1 can benefit workloads focused on performance, security, or licensing by mitigating vulnerabilities, improving performance of highly-parallel tasks, and reducing licensing costs."],["While SMT can enhance throughput for general computing and I/O-intensive tasks, it may hinder performance and introduce unpredictability for compute-bound jobs, where turning it off can allow more predictable performance and decrease job times."],["Setting the threads per core can be done during VM creation or on existing VMs using the Google Cloud console, the gcloud CLI, or the Compute Engine API, but certain machine types have limitations on this setting."],["Users should be aware that while disabling SMT changes how cores are counted and may alter the cost per core, the overall cost-effectiveness for compute-bound jobs should be evaluated based on the cost per workload or per job, as disabling SMT can reduce runtime and overall cost."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4