Create reservations for virtual machine (VM) instances in a specific zone, using custom or predefined machine types, with or without additional GPUs or local SSDs, to ensure resources are available for your workloads when you need them. After you create a reservation, you begin paying for the reserved resources immediately, and they remain available for your project to use indefinitely, until the reservation is deleted.
Use reservations to ensure that your project has resources for future increases in demand, including planned or unplanned spikes, migrating a large number of VMs, backup and disaster recovery, or for planned growth and buffer.
When you no longer need a reservation, delete the reservation to stop incurring charges for it. Because reservations consume resources just like normal VMs, each reservation is charged based on existing on-demand rates, which include sustained use discounts, and are eligible for committed use discounts.
Before you begin
- If you want to use the command-line examples in this guide:
- Install or update to the latest version of the gcloud command-line tool.
- Set a default region and zone.
- If you want to use the API examples in this guide, set up API access.
Benefits
Reservations provide the following benefits:
- Machines are always available, even if you don't use them immediately.
No time constraints. Create a reservation at any time and delete it at any time to stop paying for it.
Discounts. Because we bill for reservations in the same way and at the same rate as the resources that they are reserving, reserved resources qualify for committed- and sustained-use discounts.
Limitations and restrictions
Reservations have the following limitations and restrictions:
- Reservations apply only to Compute Engine, Dataproc, and Google Kubernetes Engine VM usage.
- Reservations don't apply to the following resources:
f1-micro
,g1-small
,e2-micro
,e2-small
,e2-medium
machine types- Preemptible VMs
- Sole-tenant nodes
- Other services not listed above, like Cloud SQL and Dataflow
- You can reserve up to 1,000 VM instances per reservation.
- You must have sufficient quota in your project for the resources you are reserving. If the reservation is successful, quota for that resource is charged accordingly.
- Resources are allocated when the reservation is created. If there aren't enough resources in the zone at the time of the request, the reservation fails with an insufficient capacity error.
- When combined with a committed use discount:
- For committed use discounted pricing for GPUs and local SSDs, a reservation must be created when purchasing the commitment.
- If the reservation is attached to a commitment, the reservation cannot be deleted.
- You can only buy a 1-year commitment on K80 GPUs.
- Reservations that aren't attached to a committed use discount can be held for any duration, but the same minimum charge of 1 minute applies as for regular instances.
How reservations work
Create reservations to reserve the VM instances you need. After you create a reservation, the reservation ensures that those resources are always available for you to use. During the creation process, you can choose how a reservation is to be used. For example, you can choose for a reservation be automatically applied to any new or existing instances that match the reservation's properties (the default behavior), or specify that only a specific VM instance can consume a reservation.
In all cases, a VM instance can only use a reservation if its properties exactly match the properties of the reservation. Specifically, for an instance to consume a reservation, the instance must match the reservation's properties for:
- Zone
- Machine type (cores and memory)
- Minimum CPU platform
- GPU type
- GPU count
- Local SSD interface
- Local SSD size
If a VM instance does match a reservation's properties, the default behavior is
for all existing and new VM instances to consume the reservation automatically
unless otherwise specified. For example, by default, if you create a reservation
for 10 custom-8-10240
instances, and you already have 5 matching
custom-8-10240
instances, then those 5 instances consume 5 of the
reservations. If you create an additional 3 matching instances, then another 3
reservations are consumed.
You can override this default behaviour by specifying certain options when creating reservations and instances.
- To create a reservation that you don't want to be consumed automatically,
use the
specificReservationRequired
option. These reservations can only be used if you explicitly specify the reservation during instance creation. - To specify that you want an instance to consume a reservation, use the
reservationAffinity
option when creating the instance or in the instance template. You can specify that an instance automatically consumes from any matching reservation, doesn't automatically consume from matching reservations, or only consumes from a specific reservation.
If you stop, suspend, or delete an instance that is using a reservation, the instance no longer counts against the reservation and the reserved resources are available again.
If you delete a reservation but don't delete the instances that are using the reserved resources, the instances persist and you pay for them as usual.
Creating a reservation
Create a reservation for VM instances using the console, the gcloud
command-line tool,
or the API. By default, any VM instances that match a reservation's properties
automatically consume that reservation. To create a reservation that isn't
consumed automatically, use the specificReservationRequired
option.
You don't need to create a commitment in order to reserve resources. However, if you want committed use discount pricing on GPUs or local SSDs, you must create a reservation that includes those resources at the same time when purchasing your commitment. For more information, see Combining reservations with committed use discounts.
Console
In the Google Cloud Console, go to the Committed use discounts page.
Click Create reservation to create a standalone reservation that has no parent commitment.
Name your reservation.
If you only want to use this reservation's resources when creating matching instances that specifically target this reservation by name, under Use with VM instance, choose Select specific reservation.
Choose the Region and Zone where you want to reserve resources.
Specify the Number of VM instances that you want to reserve.
Specify the resources that you want to reserve for each instance:
- If you have an instance template, click Use instance template and select an instance template from the list.
- Otherwise, click Specify machine type.
- For predefined machine types, select what you need from the list.
- For custom machine types, including a minimum CPU platform, or to add GPUs, click Customize and make your selections.
- Optionally, specify the number of Local SSD disks that you want to add to each instance and specify the Interface type to use.
Click Create to create the reservation.
gcloud
Use the gcloud compute reservations create
command to create a new reservation.
gcloud compute reservations create RESERVATION_NAME \ --machine-type=MACHINE_TYPE \ --min-cpu-platform MINIMUM_CPU_PLATFORM \ --vm-count=NUMBER_OF_VMS \ --accelerator=count=NUMBER_OF_ACCELERATORS,type=ACCELERATOR_TYPE \ --local-ssd=size=SIZE_IN_GB,interface=INTERFACE \ --require-specific-reservation \ --zone=ZONE
Replace the following:
RESERVATION_NAME
: the name of the reservation to create.MACHINE_TYPE
: the machine type. For example,n1-standard-2
. For custom machine types, use the formatcustom-CPUS-MEMORY
, replacing the following:CPUS
: the number of vCPUs.MEMORY
: the total memory for this instance. Memory must be a multiple of 256 MB and must be supplied in MB; for example, 5 GB of memory is 5120 MB:custom-4-5120
. For a full list of restrictions, read the Specifications for custom machine types.
MINIMUM_CPU_PLATFORM
: the minimum CPU to use for each instance.NUMBER_OF_VMS
: the quantity of VM instances to reserve.NUMBER_OF_ACCELERATORS
: the number of GPUs to add, per instance.ACCELERATOR_TYPE
: the type of accelerator.SIZE_IN_GB
: the amount, in GB, of the local SSD to attach to each instance. The amount must be a multiple of 375.INTERFACE
: the type of interface you want the local SSD for each instance to use. Valid options are:scsi
andnvme
.ZONE
: the zone in which to reserve resources.
Optionally, add the --require-specific-reservation
flag to indicate
that only VM instances that explicitly target this reservation can use it.
For more information about configuration options for consuming reserved
resources, see How reservations work.
For example, to make a reservation in us-central1-a
that can only be
used when this reservation is specifically targeted, use a command
similar to the following. This example reserves 10 custom machines, each
with 8 Intel Haswell (or more recent) vCPUs, 10 GB of memory,
2 V100 GPUs, and 375 GB local SSD:
gcloud compute reservations create my-reservation \ --machine-type=custom-8-10240 \ --min-cpu-platform "Intel Haswell" \ --vm-count=10 \ --accelerator=count=2,type=nvidia-tesla-v100 \ --local-ssd=size=375,interface=scsi \ --require-specific-reservation \ --zone us-central1-c
To see a list of all available flags, see the
gcloud compute reservations create
reference.
API
In the API, construct a POST
request to the
reservations.insert
method. In the request body, include the following parameters:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations { "name":"RESERVATION_NAME", "specificReservation":{ "count":"NUMBER_OF_VMS", "instanceProperties":{ "machineType":"MACHINE_TYPE", "minCpuPlatform": "MINIMUM_CPU_PLATFORM", "guestAccelerators":[ { "acceleratorCount":"NUMBER_OF_ACCELERATORS", "acceleratorType":"ACCELERATOR_TYPE" } ], "localSsds":[ { "diskSizeGb":"SIZE_IN_GB", "interface":"INTERFACE" } ] } } }
Replace the following:
PROJECT_ID
: the project ID for the request.ZONE
: the zone in which to reserve resources.RESERVATION_NAME
: the name of the reservation to create.NUMBER_OF_VMS
: the quantity of VM instances to reserve.MACHINE_TYPE
: a predefined or custom machine type. For example,n1-standard-2
. For custom machine types, use the formatcustom-CPUS-MEMORY
, replacing the following:CPUS
: the number of vCPUs.MEMORY
: the total memory for this instance. Memory must be a multiple of 256 MB and must be supplied in MB; for example, 5 GB of memory is 5120 MB:custom-4-5120
. For a full list of restrictions, read the Specifications for custom machine types.
MINIMUM_CPU_PLATFORM
: the minimum CPU to use for each instance.NUMBER_OF_ACCELERATORS
: the number of GPUs to add, per instance.ACCELERATOR_TYPE
: the type of accelerator.SIZE_IN_GB
: the amount, in GB, of the local SSD to attach to each instance. The amount must be a multiple of 375.INTERFACE
: the type of interface that you want the local SSD for each instance to use. Valid options are:scsi
andnvme
.
Optionally, include the specificReservationRequired
Boolean field
to specify that only VM instances that specifically target this reservation
by name can use this reservation. For more information about configuration
options for using the instances in your reservations, see
How reservations work.
For example, to make a reservation in us-central1-a
that can only be
used when this reservation is specifically targeted, use a command
similar to the following. This example reserves 10 custom machines, each
with 8, Intel Haswell (or more recent) vCPUs, 10 GB of memory,
2 V100 GPUs, and a 375 GB local SSD:
POST https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/reservations { "name": "reservation-1", "specificReservation": { "count": "10", "instanceProperties": { "machineType": "custom-8-10240", "minCpuPlatform": "Intel Haswell", "guestAccelerators": [ { "acceleratorCount": 2, "acceleratorType": "nvidia-tesla-v100" } ], "localSsds": [ { "diskSizeGb": "375", "interface": "SCSI" } ] } }, "specificReservationRequired": true }
Consuming reserved instances
When you create an instance, set the instance's reservation affinity flag to choose if the instance can use any available matching reservation (default), use a specific reservation, or use no reservation at all. For an instance to consume from a specific reservation, that reservation must be created with the corresponding specific reservation required flag.
To consume the reservation, the instances you create must match that reservation's instance properties. See How reservations work.
Consuming instances from any matching reservation
In this model, existing and new instances automatically count against the reservation if those instance's properties match the reserved instance's properties. This model is useful when you create and delete lots of VMs and you want the reservations to be used whenever possible.
When creating your reservations, exclude the --require-specific-reservation
flag, so that matching instances can consume from these reservations
automatically.
Console
Create an open reservation.
In the Cloud Console, go to the Committed use discounts page.
To create a standalone reservation that has no parent commitment, click Create reservation.
Name your reservation, for example:
reservation-01
.Under Use with VM instance, select Use reservation automatically, so that any matching instances can automatically use this reservation.
Choose the Region and Zone where you want to reserve resources.
Specify the Number of VM instances that you want to reserve.
Specify the resources that you want each instance to have:
- Number of vCPUs
- Minimum CPU platform
- Amount of memory
- GPUs
- Local SSD (as required)
Click the Create button to create the reservation.
Create a VM instance that targets any open reservation and that matches the instance properties in
reservation-01
, including the zone, machine type (vCPU count and memory amount), minimum CPU platform, GPU amount and type, and local SSD interface and size.In the Cloud Console, go to the VM instances page.
Select your project and click Continue.
Click Create instance.
Specify a Name for your instance.
Specify a Machine type that matches the properties of
reservation-01
. For example, if you specified a minimum CPU platform or GPUs in the reservation, then, to consume the reservation, you must customize this instance to match the reservation.If your reservation includes local SSDs, under Disks, click Add new disk to add local SSDs that match the reservation's local SSD interface and amount.
Under Management, under Reservations, select Automatically use created reservation.
Click Create.
gcloud
Create an open reservation called
reservation-01
.gcloud compute reservations create reservation-01 \ --machine-type=n2-standard-32 \ --min-cpu-platform "Intel Cascade Lake" \ --vm-count=2 \ --zone=us-central1-a
Create a VM instance that targets any open reservation and that matches the instance properties in
reservation-01
, including the zone, machine type (vCPU count and memory amount), minimum CPU platform, GPU amount and type, and local SSD interface and size.gcloud compute instances create instance-1 \ --machine-type=n2-standard-32 \ --min-cpu-platform "Intel Cascade Lake" \ --zone=us-central1-a \ --reservation-affinity=any
API
Create an open reservation named
reservation-01
.POST https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/reservations { "name":"reservation-01", "specificReservation":{ "count":"2", "instanceProperties":{ "machineType":"n2-standard-32", "minCpuPlatform": "Intel Cascade Lake", } }, "specificReservationRequired": false }
Create a VM instance that targets any open reservation and that matches the instance properties in
reservation-01
, including the zone, machine type (vCPU count and memory amount), minimum CPU platform, GPU amount and type, and local SSD interface and size.POST https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances { "name": "instance-1", "machineType": "zones/us-central1-a/machineTypes/n2-standard-32", "minCpuPlatform": "Intel Cascade Lake", "reservationAffinity": { "consumeReservationType": "ANY_RESERVATION" }, ... }
Consuming instances from a specific reservation
In this model, only new instances that target a specific reservation by name consume that reservation. This model is useful, for example, when you want to hold a certain amount of capacity as backup for special events.
When creating the reservation, specify that the reservation should not be used automatically. Then create VMs that specifically target that reservation and that match its properties.
If you are using an instance template to create VMs in a regional managed instance group, create identical reservations with the same name in each applicable zone. Then, target the reservations by name in the group's instance template.
For example, create a specific reservation named reservation-02
, and then
create a matching instance that targets that reservation and that matches the
reservation's instance properties.
Console
Create a reservation with resources that can only be used by instances that specifically target this reservation by name.
In the Cloud Console, go to the Committed use discounts page.
Click Create reservation to create a standalone reservation that has no parent commitment.
Name your reservation, for example:
reservation-02
.Under Use with VM instance, check Select specific reservation, so that only matching instances that specifically target this reservation by name can use this reservation.
Choose the Region and Zone where you want to reserve resources.
Specify the Number of VM instances that you want to reserve.
Specify the resources that you want each instance to have:
- Number of vCPUs
- Minimum CPU platform
- Amount of memory
- GPUs
- Local SSD
Click Create.
Create a VM instance that targets that specific reservation by name.
Ensure that the instance's properties match the instance properties of that specific reservation, including the zone, machine type (vCPU count and memory amount), minimum CPU platform, GPU amount and type, and local SSD interface and size.
In the Cloud Console, go to the VM instances page.
Select your project and click Continue.
Click the Create instance button.
Specify a Name for your instance.
Specify a Machine type that matches the properties of
reservation-01
. For example, if you specified a minimum CPU platform in the reservation, then, to consume the reservation, you must customize this instance to match the reservation.If your reservation includes local SSDs, under Disks, click Add new disk to add local SSDs that match the reservation's local SSD interface and amount.
Under Management, under Reservations, select an available reservation with matching properties, for example:
reservation-02
.Click Create to create the instance.
gcloud
Create a reservation named
reservation-02
with the--require-specific-reservation
flag. These reserved resources can be used only by instances that specifically target this reservation by name.gcloud compute reservations create reservation-02 \ --machine-type=n2-standard-32 \ --min-cpu-platform "Intel Cascade Lake" \ --vm-count=10 \ --zone=us-central1-a \ --require-specific-reservation
Create a VM instance that targets
reservation-02
by name by using the--reservation-affinity
and--reservation
flags.Ensure that the instance's properties match the reservation's instance properties, including the zone, machine type (vCPU count and memory amount), minimum CPU platform, GPU amount and type, and local SSD interface and size.
gcloud compute instances create instance-2 \ --machine-type=n2-standard-32 \ --min-cpu-platform "Intel Cascade Lake" \ --zone=us-central1-a \ --reservation-affinity=specific \ --reservation=reservation-02
API
Create a reservation named
reservation-02
with thespecificReservationRequired
field set totrue
.POST https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/reservations { "name":"reservation-02", "specificReservation":{ "count":"10", "instanceProperties":{ "machineType":"n2-standard-32", "minCpuPlatform": "Intel Cascade Lake", } }, "specificReservationRequired": true }
Create a VM instance that targets
reservation-02
by name by using thereservationAffinity
field.Ensure that the instance's properties match the reservation's instance properties, including the zone, machine type (vCPU count and memory amount), minimum CPU platform, GPU amount and type, and local SSD interface and size.
POST https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances { "name": "instance-2", "machineType": "zones/us-central1-a/machineTypes/n2-standard-32", "minCpuPlatform": "Intel Cascade Lake", "reservationAffinity": { "consumeReservationType": "SPECIFIC_RESERVATION", "key": "compute.googleapis.com/reservation-name", "values": ["reservation-02" ] }, ... }
Creating instances without consuming reservations
To explicitly avoid consuming resources from any reservation, set the reservation affinity flag to "none" when creating the VM. Or, to implicitly avoid using up any of your reservations, create an instance that doesn't match the instance properties of any of your reservations.
Console
Create an instance that explicitly doesn't consume from a reservation.
In the Cloud Console, go to the VM instances page.
Click Create instance.
Create an instance as usual.
Under Management, under Reservations, select Don't use to ensure that this instance does not consume from any existing reservations.
Click Create.
gcloud
Create an instance that explicitly does not consume from a reservation.
gcloud compute instances create instance-3 --reservation-affinity=none
Or create an instance that does not match the instance properties in any of your reservations. To review your reservation properties, see listing and describing reservations.
API
Create an instance that explicitly does not consume from a reservation.
POST https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances { "machineType": "zones/us-central1-a/machineTypes/n2-standard-16", "name": "instance-3", "reservationAffinity": { "consumeReservationType": "NO_RESERVATION" }, ... }
Or create an instance that does not match the instance properties in any of your reservations. To review your reservation properties, see listing and describing reservations.
Ensuring utilization of reservations
If you aren't able to consume your reserved resources, review the reservation's properties and the instance's properties. To test that the instance's properties match the reservation's properties, create a specific reservation, and then create an instance that targets that specific reservation.
Verify reservation properties
The reservation's instance properties must match the properties in your instance creation command. To verify:
Check the reservation's properties specifically for:
zone
specificReservationRequired
- If set to
true
, your instance creation command must target this reservation by name.
- If set to
machineType
guestAccelerators.acceleratorType
guestAccelerators.acceleratorCount
minCpuPlatform
- If you have a VM instance with a
minCpuPlatform
, and you want to create a reservation that uses that instance, create the reservation with matching properties, including a matchingminCpuPlatform
. - If you have a reservation with a
minCpuPlatform
, and you want to create an instance that uses that reservation, create the instance with matching properties, including a matchingminCpuPlatform
.
- If you have a VM instance with a
localSsds.diskSizeGb
localSsds.interface
Create an instance that matches those properties.
Describe the instance to verify that its properties match the reservation's. For example, with the
gcloud
tool, use theinstances describe
command.Describe your reservation to check that its
inUseCount
has incremented.- If the
inUseCount
has not changed, the properties are mismatched. - If the
inUseCount
has incremented, your reservation is being used.
- If the
Target a specific reservation
If you attempt to create an instance that targets a specific reservation, the instance cannot be created unless it matches the reservation's properties. Use this method to verify that you have the correct instance properties.
- Create a reservation with
the
specificReservationRequired
option. - Create an instance that explicitly matches
the reservation's instance properties and that
targets the reservation
by name through the reservation affinity property.
- If instance properties are mismatched, you see an error.
- If instance properties match, your reservation is being used.
Listing and describing reservations
List and view details about your reservation using the console, the
gcloud
tool, or the API.
Console
In the Cloud Console, go to the Committed use discounts page.
Click Reservations.
The list of reservations includes details about each reservation. You can use the Machines used (total) column to determine the utilization of each reservation.
gcloud
List your reservations with the
gcloud compute reservations list
command:
gcloud compute reservations list [--filter="zone:('ZONE')"]
NAME IN_USE_COUNT COUNT ZONE
reservation-04 25 50 us-central1-a
reservation-05 0 100 us-central1-b
Describe your reservations with the
gcloud compute reservations describe
command:
gcloud compute reservations describe RESERVATION_NAME --zone=ZONE
kind: compute#reservation
name: reservation-05
selfLink: https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-east1-d/reservations/reservation-05
specificReservation:
count: '50'
inUseCount: '25'
instanceProperties:
guestAccelerators:
- acceleratorCount: 1
acceleratorType: nvidia-tesla-k80
localSsds:
- diskSizeGb: '375'
interface: SCSI
machineType: n1-standard-2
minCpuPlatform: Any CPU Platform
specificReservationRequired: false
status: READY
zone: https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-east1-d
You can use the count
and inUseCount
values to determine the utilization
of each reservation. In this example, 50 instances are reserved,
and 25 of them are currently used.
To create an instance that uses this reservation, remember to match the reservation's instance properties. For example:
gcloud compute instances create my-instance \ --accelerator=type=nvidia-tesla-k80,count=1 \ --maintenance-policy terminate \ --local-ssd=interface=SCSI \ --machine-type n1-standard-2 \ --zone us-east1-d
API
In the API, list your reservations by making a GET
request to the
reservations.list
method.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations
Describe a reservation by calling the
reservations.get
method.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations/RESERVATION_NAME
{
"id": "2533514314332214789",
"creationTimestamp": "2019-09-27T08:21:14.707-07:00",
"selfLink": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-d/reservations/reservation-05",
"zone": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-d",
"name": "reservation-05",
"specificReservationRequired": false,
"status": "READY",
"kind": "compute#reservation",
"specificReservation": {
"instanceProperties": {
"machineType": "n1-standard-2",
"guestAccelerators": [
{
"acceleratorType": "nvidia-tesla-k80",
"acceleratorCount": 1
}
],
"minCpuPlatform": "Any CPU Platform",
"localSsds": [
{
"diskSizeGb": "375",
"interface": "SCSI"
}
]
},
"count": "50",
"inUseCount": "25"
}
}
You can use the count
and inUseCount
values to determine the utilization
of each reservation. In this example 50 instances are reserved,
and 25 of them are currently used.
Modifying reservations
You can resize or delete a reservation if it is not attached to a commitment.
Resizing a reservation
You can resize the number of VMs in a reservation that are not tied to a
commitment by using the gcloud
tool or the API.
gcloud
Resize your reservation by using the
gcloud compute reservations update
command. For example:
Create a reservation for two VM instances:
gcloud compute reservations create reservation-01 \ --machine-type=n2-standard-32 \ --zone=us-central1-a \ --vm-count=2
Resize the reservation from two to ten VM instances:
gcloud compute reservations update reservation-01 \ --zone=us-central1-a \ --vm-count=10
API
In the API, construct a POST
request to the
reservations.resize
method and include the new specificSkuCount
in the request body.
The following request body updates the reservation's VM count to 10
.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations/RESERVATION_NAME/resize
{"specificSkuCount": "10"}
The update request succeeds if, at the time of the request, there are enough resources in the target zone and sufficient quota in the target region.
Deleting a reservation
You can delete reservations that aren't tied to a commitment by using the
console, the gcloud
tool, or the API.
Console
In the Cloud Console, go to the Committed use discounts page.
Click Reservations to see a list of your reservations.
Select the checkbox next to each reservation that you want to delete.
Click Delete reservation.
gcloud
You can release reservations by using the
delete
command:
gcloud compute reservations delete RESERVATION_NAME --zone ZONE
API
In the API, construct a DELETE
request to the
reservation.delete
method.
DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations/RESERVATION_NAME
After the delete command completes successfully, you are no longer charged for the reservation, and the resources are no longer reserved for you. Deleting a reservation has no effect on any running instances that were tied to that reservation; you are still charged for those instances.
Combining reservations with Committed use discounts
A committed use discount provides a 1- or 3-year discounted price agreement, but it does not reserve capacity in a specific zone. A reservation ensures that capacity is held in a specific zone even if the reserved VMs are not running. By combining a reservation with a commitment, you can get discounted, reserved resources.
By default, when you create a reservation, any applicable committed use discounts for cores and memory are automatically applied to your VM instances. However, to get committed use discount rates for GPUs and local SSDs, you must create a reservation for those resources when purchasing the commitment.
After you purchase a commitment, you cannot cancel it. For more information, see Committed use discounts.
Purchasing a commitment for GPUs or local SSDs
To purchase a commitment for GPUs or local SSDs:
- You must purchase a general-purpose N1 commitment. GPUs are only supported with N1 machine types (with the exception of the A100 GPUs).
- You must create a reservation that includes either GPUs or local SSDs at the same time when you are purchasing your commitment.
- You do not need to commit to vCPUs or memory.
You must purchase commitments for specific GPU types. For example, you might purchase either NVIDIA P100s or NVIDIA V100s, but you cannot purchase commitments for NVIDIA P100 GPUs and expect to apply them to other GPU types.
The amount of GPUs and local SSDs that you reserve must be equal to the amount that you commit to. For example, if you want to reserve 4 V100 GPUs, then you must also commit to 4 V100 GPUs. However, the amount of vCPU and memory that you reserve can be more or less than what you commit to.
If you only want to commit to GPUs or local SSDs, you can specify 0 for vCPU and memory commitments. But the reservation that you attach to your commitment must contain the same GPUs and local SSDs as the commitment, as well as the machine types (with vCPUs and memory) that you want to reserve.
Purchase a commitment with an attached reservation using the
Cloud Console, the gcloud
tool, or the API.
Console
In the Google Cloud Console, go to the Committed use discounts page.
To purchase a new commitment, click Purchase commitment.
Name your commitment, and choose the region where you want it to apply.
For Commitment type, select General Purpose.
Choose a commitment Duration of 1 or 3 years.
Enter the quantity of Cores and Memory that you want to purchase. If you only want to commit to and reserve GPUs or local SSDs without committing to vCPUs and memory, specify 0 for the vCPU and memory commitment quantities.
Click Add GPUs and select the GPU type and Number of GPUs that you want to commit to.
Click Add local SSD and specify the number of disks that you want to commit to.
Click Add new reservation to create one or more reservations for instances that will use the GPUs and local SSDs.
- Name your reservation.
- Under Use with VM instance:
- If you want to use this reservation's resources only when creating matching instances that specifically target this reservation by name, select Select specific reservation.
- If you want matching instances to automatically use this reservation, select Use reservation automatically.
- Choose the Zone where you want to reserve resources.
- Specify the Number of VM instances that you want to reserve.
- Specify the resources that you want to reserve for each instance:
- If you have an instance template, click Use instance template and select an instance template from the list.
- Otherwise, click Specify machine type.
- Click Customize to use the slider to select the Cores and Memory for your machine type.
- Specify the CPU platform.
- To add GPUs, enter the number of GPUs and the GPU type.
- Optionally, specify the number of Local SSDs that you want to add to each instance and specify the Interface type to use.
- Click the Done button to create the reservation.
Click the Purchase button to purchase the commitment.
Read the terms of purchase and click Purchase when you are ready to purchase the commitment.
gcloud
Use the gcloud compute commmitments create
command
to purchase a commitment, and include flags to create an attached
reservation.
For example, the following commitment includes 4 GPUs and a new reservation
for those 4 GPUs to be used across 2 n1-standard-32
instances in
us-central1-a
.
gcloud compute commitments create commitment-01 \ --region=us-central1 \ --resources=vcpu=96,memory=624GB \ --resources-accelerator=type=nvidia-tesla-v100,count=4 \ --plan 12-month \ --reservation=reservation-01 \ --reservation-zone=us-central1-a \ --machine-type=n1-standard-16 \ --accelerator=type=nvidia-tesla-v100,count=2 \ --vm-count=2
If you want to commit to and reserve GPUs or local SSDs without committing to vCPUs and memory, specify 0 for the vCPU and memory commitment quantities.
gcloud compute commitments create commitment-01 \ --region=us-west2 \ --resources=vcpu=0,memory=0 \ --resources-accelerator=type=nvidia-tesla-p4,count=1 \ --plan 12-month \ --reservation=reservation-01 \ --reservation-zone=us-west2-b \ --machine-type=n1-standard-2 \ --accelerator=type=nvidia-tesla-p4,count=1 \ --vm-count=1
To create multiple reservations when purchasing a commitment, use a YAML file that contains the reservation properties. For example:
gcloud compute commitments create commitment-01 \ --region=us-central1 \ --resources=vcpu=96,memory=624,local-ssd=750 \ --resources-accelerator=type=nvidia-tesla-v100,count=1 \ --plan 12-month \ --reservations-from-file=YAML_FILE
For example, the following YAML file contains 2 reservations. The first
reservation, res-01
, contains 1 n1-standard-2
instance with 1 GPU, and
it is a targeted reservation, which means that you must specifically target
that reservation by name to use its reserved instances. The second
reservation, res-02
, contains 1 n1-standard-2
VM instance with 2 types
of attached local SSDs.
‐ reservation: res-01 reservation_zone: us-central1-a require_specific_reservation: true vm_count: 1 machine_type: n1-standard-2 accelerator: ‐ count: 1 type: nvidia-tesla-v100 ‐ reservation: res-02 reservation_zone: us-central1-a vm_count: 1 machine_type: n1-standard-2 local_ssd: ‐ interface: scsi size: 375 ‐ interface: nvme size: 375
API
Use the regionCommitments.insert
method
and include the reservations
field to define the reservation's
properties. For example, the following commitment includes 4 GPUs and a
reservation for those 4 GPUs to be used across 2 instances in
us-central1-a
.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/commitments { "name": "commitment-01", "plan": "TWELVE_MONTH", "resources": [ { "amount": "96", "type": "VCPU" }, { "amount": "638976", "type": "MEMORY" }, { "acceleratorType": "nvidia-tesla-v100", "amount": "4", "type": "ACCELERATOR" } ], "reservations": [ { "name": "reservation-01", "specificReservation": { "count": "2", "instanceProperties": { "guestAccelerators": [ { "acceleratorCount": 2, "acceleratorType": "nvidia-tesla-v100" } ], "machineType": "n1-standard-8" } }, "specificReservationRequired": false, "zone": "us-central1-a" } ] }
If you only want to commit to and reserve GPUs or local SSDs without committing to vCPUs and memory, specify 0 for the vCPU and memory commitment quantities. For example:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/commitments { "name": "commitment-01", "plan": "TWELVE_MONTH", "resources": [ { "amount": "0", "type": "VCPU" }, { "amount": "0", "type": "MEMORY" }, { "acceleratorType": "nvidia-tesla-v100", "amount": "4", "type": "ACCELERATOR" } ], "reservations": [ { "name": "reservation-01", "specificReservation": { "count": "2", "instanceProperties": { "guestAccelerators": [ { "acceleratorCount": 2, "acceleratorType": "nvidia-tesla-v100" } ], "machineType": "n1-standard-8" } }, "specificReservationRequired": false, "zone": "us-central1-a" } ] }
The commitment is successfully created only if there are enough resources in the target zone, and sufficient quota, at the time of the request.
When you create a commitment with an attached reservation, you cannot delete the reservation for the duration of the commitment. When your commitment expires, Compute Engine automatically deletes any attached reservations.
If you need to transfer GPUs or local SSDs across committed reservations, see Modifying reservations that are attached to commitments.
Modifying reservations that are attached to commitments
If a commitment has one or more reservations with GPUs or local
SSDs, you can use the gcloud
tool or the API to transfer GPUs or
local SSDs across those reservations. For example, you might move GPUs from
one reservation to a second, new reservation.
Limitations:
- You can only move resources between two reservations, where one is the source reservation and the other is the destination. The source reservation must already exist; the destination can be an existing or new reservation.
- The source and destination reservations must be in the same zone.
- You cannot modify the resource properties in existing reservations; you can only transfer existing resources from one reservation to another.
- The total amount of GPUs and local SSDs must remain constant.
- You can only change 100 VMs per request. If you want to update more, call the API multiple times or reach out to Google Cloud Support.
You cannot transfer vCPUs or memory or modify other properties of attached reservations.
gcloud
Use the gcloud beta compute commitments update-reservations
command.
Create a commitment with one reservation:
res-1
has 4n1-standard-2
instances, each with 1 P100 GPU (4 vCPUs and 4 P100 GPUs). The total reserved resources includes 4 P100 GPUs.
gcloud beta compute commitments create my-commitment-with-reservations \ --region=asia-east1 \ --resources=vcpu=10,memory=32GB \ --resources-accelerator=type=nvidia-tesla-p100,count=4 \ --plan 12-month \ --reservations-from-file=one-reservation.yaml
The one-reservation.yaml
file contains:
- reservation: res-1
reservation_zone: asia-east1-a
require_specific_reservation: true
vm_count: 4
machine_type: n1-standard-2
accelerator:
- count: 1
type: nvidia-tesla-p100
Update the commitment to transfer some resources from res-1
to a new,
second reservation, res-2
. In this example:
- Modify
res-1
to have 2n1-standard-2
instances, each with 2 P100 GPUs (2 vCPU and 2 P100 GPUs). - Add
res-2
to have 2n1-standard-2
instances each with 1 P100 GPU (4 vCPUs and 2 P100 GPUs).
The total number of reserved GPUs within the commitment remains constant at 4.
gcloud beta compute commitments update-reservations my-commitment-with-reservations \ --region=us-central1 \ --reservations-from-file=two-reservations.yaml
The two-reservations.yaml
file contains:
- reservation: res-1
reservation_zone: asia-east1-a
require_specific_reservation: true
vm_count: 2
machine_type: n1-standard-2
accelerator:
- count: 1
type: nvidia-tesla-p100
- reservation: res-2
reservation_zone: asia-east1-a
require_specific_reservation: true
vm_count: 2
machine_type: n1-standard-2
accelerator:
- count: 1
type: nvidia-tesla-p100
API
Use the regionCommitments.updateReservations
method.
For example, create a commitment with the following reservation:
res-1
has 4n1-standard-2
instances each with 1nvidia-tesla-p100
GPU (4 vCPUs and 4 P100 GPUs).
In this example, the total reserved resources includes 4 P100 GPUs.
POST https://compute.googleapis.com/compute/beta/projects/my-project/regions/asia-east1/commitments/my-commitment-with-reservation/updateReservations { "name": "my-commitment-with-reservation", "plan": "TWELVE_MONTH", "reservations": [ { "name": "res-1", "specificReservation": { "count": "4", "instanceProperties": { "guestAccelerators": [ { "acceleratorCount": 1, "acceleratorType": "nvidia-tesla-p100" } ], "machineType": "n1-standard-2" } }, "specificReservationRequired": true, "zone": "asia-east1-a" } ], "resources": [ { "amount": "10", "type": "VCPU" }, { "amount": "32768", "type": "MEMORY" }, { "acceleratorType": "nvidia-tesla-p100", "amount": "4", "type": "ACCELERATOR" } ] }
Update the commitment to transfer some resources from res-1
to a new,
second reservation, res-2
. In this example:
- Modify
res-1
to have 2n1-standard-2
instances, each with 2 P100 GPUs (2 vCPU and 2 P100 GPUs). - Add
res-2
to have 2n1-standard-2
instances each with 1 P100 GPU (4 vCPUs and 2 P100 GPUs).
The total number of reserved GPUs within the commitment remains constant at 4.
POST https://compute.googleapis.com/compute/beta/projects/my-project/regions/asia-east1/commitments/my-commitment-with-reservation/updateReservations { "reservations": [ { "name": "res-1", "specificReservation": { "count": "2", "instanceProperties": { "guestAccelerators": [ { "acceleratorCount": 1, "acceleratorType": "nvidia-tesla-p100" } ], "machineType": "n1-standard-2" } }, "specificReservationRequired": true, "zone": "asia-east1-a" }, { "name": "res-2", "specificReservation": { "count": "2", "instanceProperties": { "guestAccelerators": [ { "acceleratorCount": 1, "acceleratorType": "nvidia-tesla-p100" } ], "machineType": "n1-standard-2" } }, "specificReservationRequired": true, "zone": "asia-east1-a" } ] }
Viewing reservation usage reports
Export detailed reports of your Compute Engine usage to a Cloud Storage bucket using the usage export feature. See Viewing usage reports for instructions.
The usage report shows:
- Reserved resources that are in use. These entries appear as normal vCPU, memory, GPU, and local SSD resources.
- Reserved resources that are not in use. These entries have normal SKU names and reservation resource URIs.
- Total reserved resources. These entries have reservation SKU names and reservation resource URIs. There are no costs associated with these entries. Use these entries to calculate how much of your reservations you are using.
Measurement | MeasurementId format
|
Resource URI format
|
---|---|---|
Reserved resources that are in use | com.google.cloud/services/compute-engine/SKU_NAME
|
https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/RESOURCE_TYPE/RESOURCE_NAME .
For example, https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances/my-instance
|
Reserved resources that are not in use | com.google.cloud/services/compute-engine/SKU_NAME
|
https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations/RESERVATION_NAME .
For example, https://compute.googleapis.com/compute/v1/projects/my-project/zones/europe-west1-a/reservations/my-reservation
|
Total reserved resources | com.google.cloud/services/compute-engine/ReservationSKU_NAME
|
https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations/RESERVATION_NAME .
For example, https://compute.googleapis.com/compute/v1/projects/my-project/zones/europe-west1-a/reservations/my-reservation
|
For example, in the following snippet from a usage report for a reservation
named my-reservation
:
- Row 1 shows reserved RAM that is currently in use. The row's
ResourceId
shows that this RAM is used by an instance namedmy-instance
. - Row 2 shows reserved RAM that is not in use. The row's
ResourceId
shows that this reserved RAM is held bymy-reservation
; it is not yet used by any instance. - Row 3 shows the reservation's total reserved RAM.
Report Date,MeasurementId,Quantity,Unit,Resource URI,ResourceId,Location 2019-06-06,com.google.cloud/services/compute-engine/VmimageN2StandardRam,166970074857472,byte-seconds,https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central2-a/instances/my-instance,1775485842510981624,us-central2-a 2019-06-06,com.google.cloud/services/compute-engine/VmimageN2StandardRam,166970074857472,byte-seconds,https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central2-a/reservations/my-reservation,7.58809E+17,us-central2-a 2019-06-06,com.google.cloud/services/compute-engine/ReservationN2StandardRam,333940149714944,byte-seconds,https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central2-a/reservations/my-reservation,7.58809E+17,us-central2-a ...
Reservation billing
Reservations are billed at the same rate as the resources that they are reserving. Sustained use discounts, committed use discounts and custom pricing apply as they would for regular VMs.
Take the following example:
- You have a 3-vCPU commitment in
us-central1
- You are running 5 vCPUs in
us-central1-a
- You have a 10-vCPU reservation in
us-central1-a
You will be billed as follows:
Covered by | # of vCPUs |
---|---|
Committed use discount price | 3 |
On-demand price (2 vCPU used reservations + 5 vCPU unused reservations) | 7 |
What's next
- Learn more about committed use discounts