Customize the number of visible CPU cores Stay organized with collections Save and categorize content based on your preferences.
Customizing the number of visible CPU cores can provide granular control overlicensing costs, while maintaining the performance of networking and persistentdisks. This customization reduces the number of vCPUs that are available to thevirtual machine (VM) instance; it doesn't change the machine type or price.
Compute Engine implements each virtual CPU (vCPU) as a single hardwaremultithread that runs on a physical CPU core. To reduce the number of vCPUs thatare available to a VM, Compute Engine lets you customize the number ofvisible CPU cores.
Visible cores are the CPU cores in the underlying hardware that your VMsconsume. By default, the number of CPU cores that are visible to a VM is thenumber of vCPUs on the machine type divided by the number ofthreads percore:
Visible CPU cores =vCPUs on the machine type /threads per core
For example, thec2-standard-60 machine type specifies 60 vCPUs. Assuming thedefault of 2 threads per core, the number of visible CPU cores is 30. If youreduce the number of visible cores from 30 to 20, the number of functional vCPUsis reduced from 60 to 40.
Consider customizing the number of visible CPU cores if both of the followingapply:
You run software, such asWindows Server or SQL Server,that is licensed based on the number of available vCPUs.
You usepredefined machine types, whichdon't let you modify the number of vCPUs or the amount of RAM.
Before customizing the number of vCPUs that are available to a VM, firstconsider using acustom machine type.
Required roles
To get the permissions that you need to customize the number of visible CPU cores, ask your administrator to grant you theCompute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on the project. For more information about granting roles, seeManage access to projects, folders, and organizations.
This predefined role contains the permissions required to customize the number of visible CPU cores. To see the exact permissions that are required, expand theRequired permissions section:
Required permissions
The following permissions are required to customize the number of visible CPU cores:
- To customize the number of visible CPU cores during VM creation:
compute.instances.createon the project- To use a custom image to create the VM:
compute.images.useReadOnlyon the image - To use a snapshot to create the VM:
compute.snapshots.useReadOnlyon the snapshot - To use an instance template to create the VM:
compute.instanceTemplates.useReadOnlyon the instance template - To assign alegacy network to the VM:
compute.networks.useon the project - To specify a static IP address for the VM:
compute.addresses.useon the project - To assign an external IP address to the VM when using a legacy network:
compute.networks.useExternalIpon the project - To specify a subnet for the VM:
compute.subnetworks.useon the project or on the chosen subnet - To assign an external IP address to the VM when using a VPC network:
compute.subnetworks.useExternalIpon the project or on the chosen subnet - To set VM instance metadata for the VM:
compute.instances.setMetadataon the project - To set tags for the VM:
compute.instances.setTagson the VM - To set labels for the VM:
compute.instances.setLabelson the VM - To set a service account for the VM to use:
compute.instances.setServiceAccounton the VM - To create a new disk for the VM:
compute.disks.createon the project - To attach an existing disk in read-only or read-write mode:
compute.disks.useon the disk - To attach an existing disk in read-only mode:
compute.disks.useReadOnlyon the disk
- To customize the number of visible CPU cores on a group of VMs by using an instance template: You need all the permissions you would use during VM creation and the
compute.instanceTemplates.createon the project
You might also be able to get these permissions withcustom roles or otherpredefined roles.
vCPUs and the number of threads per core
The total vCPUs on a machine type is the number of visible CPU cores multipliedby the number of threads per core. For most machine series, the number ofthreads per core is 2, but you canmanually set the number of threads percore to 1.
The following table shows how visible CPU cores, number of threads per core, andtotal available vCPUs are related using thec2-standard-60 machine type as anexample.
| Machine type | Visible CPU cores | Threads per core | Available vCPUs |
|---|---|---|---|
c2-standard-60 | 30 (default) | 2 (default) | 60 |
c2-standard-60 | 30 (default) | 1 | 30 |
c2-standard-60 | 20 | 2 (default) | 40 |
c2-standard-60 | 20 | 1 | 20 |
Performance considerations
This section explains how reducing the number of visible cores can impact theperformance of your VM.
Persistent disk
The performance limits of persistent disks depend on the machine type andaren't affected by the number of visible CPU cores. For more information, seeBlock storage performance.
Networking egress
The bandwidth limits of networking egress match the machine type and aren'taffected by the number of visible CPU cores. However, networking performancedoes vary depending on the number of vCPUs that are accessible to the VM. Forexample, an2-standard-16 machine type with one visible CPU core might notbe able to fully use a 32 Gbps connection.
Pricing
This section explains how reducing the number of visible cores can impact thecost of your VMs.
Operating system licensing costs
You can lower licensing costs for some operating systems by reducing thenumber of visible CPU cores. Applicable operating systems are those thatcharge you for each vCPU that is available to the VM; for example, WindowsServer and SQL Server. For more information about the licensing options forthese operating systems on Compute Engine, seeMicrosoftlicenses.
VM costs, quota, and capacity
VM costs, quota, and capacity remain the same when you customize the number ofvisible CPU cores because Compute Engine charges, tracks quota, andallocates space on machine types for VMs as if they are using the number ofCPU cores of the machine type. For more information about howCompute Engine bills for VMs, seeVM instance pricing.
Limitations
You cannot customize the number of visible CPU cores while a VM is in the
RUNNINGstate. For more information about VM states, seeVM instancelifecycle.In the Google Cloud console, when the number of visible cores is reduced,the CPU utilization metric can't scale up to 100%. It is limited to thenumber of visible CPU cores divided by the maximum number of CPU cores.
You can't use this feature to customize the number of visible CPU cores forbare metal instances.
Supported machine types and valid values for each
Manymachine types support customization ofthe number of visible CPU cores. The value for the visible CPU core count mustbe a whole number. The maximum value is the number of vCPUs—or GPUs foraccelerator-optimized machine types—on the machine type divided by thenumber ofthreads per core forthe VM.
The following table shows the machine types that support this customization,along with the corresponding valid values for visible CPU cores for machinetypes in those families.
| Machine type family | Predefined vCPU count* | Valid values for visible CPU cores |
|---|---|---|
| General-purpose | ||
| C4D | ≤ 192 | Any |
| C4D | > 192 | Multiples of 2 |
| C4 | 4, 8, 16, 24, 32, 48 | Any |
| C4 | 96 | Multiples of 2 |
| C4 | 144 | Multiples of 3 |
| C4 | 192 | Multiples of 4 |
| C4 | 288 | Multiples of 6 |
| C3D | ≤ 180 | Any |
| C3D | 360 | Multiples of 2 |
| C3 | 4, 8, 22, 44 | Multiples of 1 |
| C3 | 88 | Multiples of 2 |
| C3 | 176 | Multiples of 4 |
| E2 | ≤ 32 | Any |
| N2 | ≤ 32 | Any |
| N2 | > 32 | Multiples of 2 |
| N2D | ≤ 24 | Any |
| N2D | > 24 | Multiples of 2 |
| N4 | ≤ 80 | Any |
| N4D | ≤ 96 | Any |
| N1 | ≤ 64 | Any |
| N1 | > 64 | Multiples of 2 |
| N1 (TPU optimized) | 48 | Any |
| N1 (TPU optimized) | 96 | Multiples of 2 |
| Storage-optimized | ||
| Z3 | ≤ 44 | Any |
| Z3 | 88 | Multiples of 2 |
| Z3 | 176 | Multiples of 4 |
| Compute-optimized | ||
| H4D | 192 | Multiples of 4 |
| H3 | 88 | Multiples of 4 |
| C2 | 4, 8, 16, 30 | Any |
| C2 | 60 | Multiples of 2 |
| Memory-optimized | ||
| M4 | 16, 28, 32, 56 | Any |
| M4 | 64, 112 | Multiples of 2 |
| M4 | 224 | Multiples of 4 |
| M3 | 128 | Multiples of 2 |
| M3 | 32, 64 | Any |
| M2 | 208 | Multiples of 4 |
| M2 | 416 | Multiples of 8 |
| M1 | 40 | Any |
| M1 | 80, 96 | Multiples of 2 |
| M1 | 160 | Multiples of 4 |
| Accelerator-optimized | ||
| A4 | 224 | Multiples of 2 |
| A3 | 26, 52, 104, 208, 224 | Multiples of 2 |
| A2 | ≤ 48 | Any |
| A2 | 96 | Multiples of 2 |
| G2 | ≤ 48 | Any |
| G2 | 96 | Multiples of 2 |
| G4 | All machine types | Multiples of 2 |
Customize the number of visible CPU cores during VM creation
To customize the number of visible CPU cores while creating a single VM, followthe steps explained in this section.
The following example shows how to create a SQL Server VM with a reduced numberof visible CPU cores.
Console
To customize the number of visible CPU cores while creating a VM, do thefollowing:
- InMachine configuration>Advanced configurations>Visible core count, select the number of visible cores.
gcloud
To create a SQL Server VM with a reduced number of visible CPU cores, usethe followinggcloud compute instances createcommand:
gcloud compute instances createVM_NAME \ --image-project=windows-sql-cloud \ --image-family=sql-ent-2019-win-2019 \ --machine-type=MACHINE_TYPE \ --visible-core-count=VISIBLE_CORE_COUNT \ --zone=ZONE
Replace the following:
VM_NAME: the name of the VM.MACHINE_TYPE: a supported machine type, forexample,c2-standard-60.VISIBLE_CORE_COUNT: the number of visible CPUcores. For example, when using thec2-standard-60machine type, if setto20, and the number of threads per core is2, 40 of the 60 CPUs arevisible.ZONE: the zone to create the VM in.
REST
To create a SQL Server VM with a reduced number of visible CPU cores, usethe followinginstances.insertmethod:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances{ "name": "VM_NAME", ... "advanced_machine_features": { ... "visibleCoreCount": "VISIBLE_CORE_COUNT" }, ...}Replace the following:
PROJECT_ID: the ID of the project.ZONE: the zone in which to create the VM.VM_NAME: the name of the VM.VISIBLE_CORE_COUNT: the number of visible CPUcores. For example, when using thec2-standard-60machine type, if setto20, and the number of threads per core is2, 40 of the 60 CPUs arevisible.
Customize the number of visible CPU cores on a group of VMs by using an instance template
To customize the number of visible CPU cores while creating a VM by using aninstance template, follow the steps explained in this section.
The following example shows how to create a group of identical SQL Server VMswith a reduced number of visible CPU cores by using an instance template.
Console
To customize the number of visible CPU cores while creating an instancetemplate, do the following:
- InMachine configuration>Advanced configurations>Visible core count, select the number of visible cores.
gcloud
Create an instance template for SQL Server VMs, each with a reducednumber of visible CPU cores, by using the following
gcloud computeinstance-templates createcommand:gcloud compute instance-templates createINSTANCE_TEMPLATE_NAME \ --image-project=windows-sql-cloud \ --image-family=sql-ent-2019-win-2019 \ --machine-type=MACHINE_TYPE \ --visible-core-count=VISIBLE_CORE_COUNT \ --zone=ZONE
Replace the following:
INSTANCE_TEMPLATE_NAME: the name of theinstance template.MACHINE_TYPE: a supported machine type, forexample,c2-standard-60.VISIBLE_CORE_COUNT: the number of visibleCPU cores. For example, when using thec2-standard-60machine type,if set to20, and the number of threads per core is2, 40 of the60 CPUs are visible.ZONE: the zone to create the VMs in.
Create the SQL Server VMs, each with a reduced number of visible CPUcores, by using the following
gcloud compute instances createcommand:gcloud compute instances createINSTANCE_NAMES \ --source-instance-template=INSTANCE_TEMPLATE_NAME
Replace the following:
INSTANCE_NAMES: the names of the VMs,separated by spaces, to create from the instance templateINSTANCE_TEMPLATE_NAME: the name of theinstance template from which to create the VMs
REST
Create an instance template for SQL Server VMs, each with a reduced numberof visible CPU cores, by using the following
instanceTemplates.insertmethod:POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/instanceTemplates{ "name": "INSTANCE_TEMPLATE_NAME", ... "advanced_machine_features": { ... "visible_core_count": "VISIBLE_CORE_COUNT" }, ...}Replace the following:
PROJECT_ID: the ID of the project.INSTANCE_TEMPLATE_NAME: the name of theinstance template.VISIBLE_CORE_COUNT: the number of visibleCPU cores. For example, when using thec2-standard-60machine type,if set to20, and the number of threads per core is2, 40 of the60 CPUs are visible.
Create the SQL Server VMs, each with a reduced number of visible CPUcores, by using the following
instances.insertmethod:POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances?sourceInstanceTemplate=INSTANCE_TEMPLATE_NAME{ "name": "VM_NAME", ...}Replace the following:
PROJECT_ID: the ID of the projectZONE: the zone to create the VM inINSTANCE_TEMPLATE_NAME: the name of theinstance template from which to create the VMsVM_NAME: the name of the VM to create fromthe instance template
Customize the number of visible CPU cores
To customize the number of visible CPU cores on an existing VM, follow thesteps explained in this section.
If you customized the number of visible CPU cores on a group of VMs by using aninstance template, you must create a new instance template and then create newVMs from that instance template. For more information about instance templates,seeInstance templates.
Console
To customize the number of visible CPU cores on an existing VM, do thefollowing:
Stop the VM.
InMachine configuration>Advanced configurations>Visible core count, select the number of visiblecores.
Restart the VM.
gcloud
To update the value for the number of visible CPU cores on an existing VM,use the following steps. For more information, seeUpdate instanceproperties.
Export the existing VM properties to a file by using the
gcloudcompute instances exportcommand.In the file containing the exported properties, modify or add the valuefor the following:
advancedMachineFeatures: visibleCoreCount:VISIBLE_CORE_COUNT
Update the VM's properties by using the
gcloud compute instancesupdate-from-filecommand with--most-disruptive-allowed-action=RESTART.
REST
To update the visible CPU core count of the VM, use the followinginstances.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": { ... "visible_core_count": "VISIBLE_CORE_COUNT" }, ...}Replace the following:
PROJECT_ID: the ID of the projectZONE: the zone that contains the VMVM_NAME: the name of the VM from which toexport propertiesVISIBLE_CORE_COUNT: the number of visible CPUcores
What's next
Learn how toview the number of visible CPU cores.
Learn about thelicensing options for Microsoft software.
Learn how toset the number of threads per core.
Learn about theoperating systems that you can run on Compute Engine VMs.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.