Linux Windows
Customizing the number of visible CPU cores can provide granular control over licensing costs, while maintaining the performance of networking and persistent disks. This customization reduces the number of vCPUs that are available to the virtual machine (VM) instance; it doesn't change the machine type or price.
Compute Engine implements each virtual CPU (vCPU) as a single hardware multithread that runs on a physical CPU core. To reduce the number of vCPUs that are available to a VM, Compute Engine lets you customize the number of visible CPU cores.
Visible cores are the CPU cores in the underlying hardware that your VMs consume. By default, the number of CPU cores that are visible to a VM is the number of vCPUs on the machine type divided by the number of threads per core:
For example, the c2-standard-60
machine type specifies 60 vCPUs. Assuming the default of 2 threads per core, the number of visible CPU cores is 30. If you reduce the number of visible cores from 30 to 20, the number of functional vCPUs is reduced from 60 to 40.
Consider customizing the number of visible CPU cores if both of the following apply:
You run software, such as Windows Server or SQL Server, that is licensed based on the number of available vCPUs.
You use predefined machine types, which don'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, first consider using a custom machine type.
Required rolesTo get the permissions that you need to customize the number of visible CPU cores, ask your administrator to grant you the Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1
) IAM role on the project. For more information about granting roles, see Manage 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 the Required permissions section:
Required permissionsThe following permissions are required to customize the number of visible CPU cores:
compute.instances.create
on the projectcompute.images.useReadOnly
on the imagecompute.snapshots.useReadOnly
on the snapshotcompute.instanceTemplates.useReadOnly
on the instance templatecompute.networks.use
on the projectcompute.addresses.use
on the projectcompute.networks.useExternalIp
on the projectcompute.subnetworks.use
on the project or on the chosen subnetcompute.subnetworks.useExternalIp
on the project or on the chosen subnetcompute.instances.setMetadata
on the projectcompute.instances.setTags
on the VMcompute.instances.setLabels
on the VMcompute.instances.setServiceAccount
on the VMcompute.disks.create
on the projectcompute.disks.use
on the diskcompute.disks.useReadOnly
on the diskcompute.instanceTemplates.create
on the projectYou might also be able to get these permissions with custom roles or other predefined roles.
vCPUs and the number of threads per coreThe total vCPUs on a machine type is the number of visible CPU cores multiplied by the number of threads per core. For most machine series, the number of threads per core is 2, but you can manually set the number of threads per core to 1.
The following table shows how visible CPU cores, number of threads per core, and total available vCPUs are related using the c2-standard-60
machine type as an example.
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 the performance of your VM.
Persistent diskThe performance limits of persistent disks depend on the machine type and aren't affected by the number of visible CPU cores. For more information, see Block storage performance.
Networking egressThe bandwidth limits of networking egress match the machine type and aren't affected by the number of visible CPU cores. However, networking performance does vary depending on the number of vCPUs that are accessible to the VM. For example, a n2-standard-16
machine type with one visible CPU core might not be able to fully use a 32 Gbps connection.
This section explains how reducing the number of visible cores can impact the cost of your VMs.
Operating system licensing costsYou can lower licensing costs for some operating systems by reducing the number of visible CPU cores. Applicable operating systems are those that charge you for each vCPU that is available to the VM; for example, Windows Server and SQL Server. For more information about the licensing options for these operating systems on Compute Engine, see Microsoft licenses.
VM costs, quota, and capacityVM costs, quota, and capacity remain the same when you customize the number of visible CPU cores because Compute Engine charges, tracks quota, and allocates space on machine types for VMs as if they are using the number of CPU cores of the machine type. For more information about how Compute Engine bills for VMs, see VM instance pricing.
LimitationsYou cannot customize the number of visible CPU cores while a VM is in the RUNNING
state. For more information about VM states, see VM instance lifecycle.
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 the number 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 for bare metal instances.
Many machine types support customization of the number of visible CPU cores. The value for the visible CPU core count must be a whole number. The maximum value is the number of vCPUs—or GPUs for accelerator-optimized machine types—on the machine type divided by the number of threads per core for the VM.
The following table shows the machine types that support this customization, along with the corresponding valid values for visible CPU cores for machine types in those families.
Machine type family Predefined vCPU count* Valid values for visible CPU cores General-purpose C4D All machine types 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 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 H3 88 Multiples of 4 C2 4, 8, 16, 30 Any C2 60 Multiples of 2 Memory-optimized M4 28, 56 Any M4 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 (Preview) All machine types Multiples of 2 *The name for most machine types contain the vCPU count. However, for accelerator-optimized machine types other than G2 and G4, the name for the machine type contains the predefined GPU count. To see the vCPU count for the accelerator-optimized machine types, review the
Accelerator-optimized machine familydocumentation.
Customize the number of visible CPU cores during VM creationTo customize the number of visible CPU cores while creating a single VM, follow the steps explained in this section.
The following example shows how to create a SQL Server VM with a reduced number of visible CPU cores.
ConsoleTo customize the number of visible CPU cores while creating a VM, do the following:
To create a SQL Server VM with a reduced number of visible CPU cores, use the following gcloud compute instances create
command:
gcloud compute instances create VM_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, for example, c2-standard-60
.
VISIBLE_CORE_COUNT
: the number of visible CPU cores. For example, when using the c2-standard-60
machine type, if set to 20
, and the number of threads per core is 2
, 40 of the 60 CPUs are visible.
ZONE
: the zone to create the VM in.
To create a SQL Server VM with a reduced number of visible CPU cores, use the following instances.insert
method:
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 CPU cores. For example, when using the c2-standard-60
machine type, if set to 20
, and the number of threads per core is 2
, 40 of the 60 CPUs are visible.
To customize the number of visible CPU cores while creating a VM by using an instance template, follow the steps explained in this section.
The following example shows how to create a group of identical SQL Server VMs with a reduced number of visible CPU cores by using an instance template.
ConsoleTo customize the number of visible CPU cores while creating an instance template, do the following:
Create an instance template for SQL Server VMs, each with a reduced number of visible CPU cores, by using the following gcloud compute instance-templates create
command:
gcloud compute instance-templates create INSTANCE_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 the instance template.
MACHINE_TYPE
: a supported machine type, for example, c2-standard-60
.
VISIBLE_CORE_COUNT
: the number of visible CPU cores. For example, when using the c2-standard-60
machine type, if set to 20
, and the number of threads per core is 2
, 40 of the 60 CPUs are visible.
ZONE
: the zone to create the VMs in.
Create the SQL Server VMs, each with a reduced number of visible CPU cores, by using the following gcloud compute instances create
command:
gcloud compute instances create INSTANCE_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 template
INSTANCE_TEMPLATE_NAME
: the name of the instance template from which to create the VMs
Create an instance template for SQL Server VMs, each with a reduced number of visible CPU cores, by using the following instanceTemplates.insert
method:
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 the instance template.
VISIBLE_CORE_COUNT
: the number of visible CPU cores. For example, when using the c2-standard-60
machine type, if set to 20
, and the number of threads per core is 2
, 40 of the 60 CPUs are visible.
Create the SQL Server VMs, each with a reduced number of visible CPU cores, by using the following instances.insert
method:
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 project
ZONE
: the zone to create the VM in
INSTANCE_TEMPLATE_NAME
: the name of the instance template from which to create the VMs
VM_NAME
: the name of the VM to create from the instance template
To customize the number of visible CPU cores on an existing VM, follow the steps explained in this section.
If you customized the number of visible CPU cores on a group of VMs by using an instance template, you must create a new instance template and then create new VMs from that instance template. For more information about instance templates, see Instance templates.
ConsoleTo customize the number of visible CPU cores on an existing VM, do the following:
Stop the VM.
In Machine configuration > Advanced configurations > Visible core count, select the number of visible cores.
Restart the VM.
To update the value for the number of visible CPU cores on an existing VM, use the following steps. For more information, see Update instance properties.
Export the existing VM properties to a file by using the gcloud compute instances export
command.
In the file containing the exported properties, modify or add the value for the following:
advancedMachineFeatures: visibleCoreCount: VISIBLE_CORE_COUNT
Update the VM's properties by using the gcloud compute instances update-from-file
command with --most-disruptive-allowed-action=RESTART
.
To update the visible CPU core count of the 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": { ... "visible_core_count": "VISIBLE_CORE_COUNT" }, ... }
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
VISIBLE_CORE_COUNT
: the number of visible CPU cores
Learn how to view the number of visible CPU cores.
Learn about the licensing options for Microsoft software.
Learn how to set the number of threads per core.
Learn about the operating systems that you can run on Compute Engine VMs.
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