Bulk creation of virtual machine (VM) instances lets you create a large number of VMs that are identical and independent from each other. When you create VMs in bulk, you can do the following:
-
Minimize consumption of API rate limits. Requests for creating VMs in bulk consume API rate limits as if you were creating a single VM.
-
Distribute VM creation across multiple zones in a region. For regional requests, Compute Engine determines the zone to create the VMs in based on the zones that have available hardware, taking into consideration the available capacity in each zone, as well as any of your reservations.
Compute Engine doesn't manage VMs that you create in bulk. To create a group of managed VMs, use managed instance groups.
Creating VMs in bulk versus batching API requests
Creating VMs in bulk is different from batching API
requests with the instances.insert
method. The following table
compares these two ways of creating multiple VMs:
Functionality | Batching API requests | Creating VMs in bulk |
---|---|---|
Zone selection Automatically selected based on considerations such as resource availability and quota |
Manual | Automatic when using the regional endpoint |
Upfront validation Request fails immediately if it is not feasible |
No | With capacity and quota |
VM name generation Automatically generated based on a specified name pattern |
Manual | Optionally generated automatically |
Automatic rollback Request automatically rolled back if Compute Engine cannot create the target number of VMs |
No | Optionally enabled |
API rate limit How requests affect the API rate limit |
One request for each VM | One request for each bulk operation |
Limitations
The following list describes the limitations that apply when creating VMs in bulk:
Disks. You cannot create VMs that have disks that are protected by customer-supplied encryption keys (CSEK).
Global DNS. If you are using global DNS, there might be name conflicts because the fully qualified domain name (FQDN) doesn't contain the zone. To avoid this, use zonal DNS. If you cannot switch to zonal DNS, avoid using the same name pattern across different regions. For more information, see Types of internal DNS names.
Machine images. You cannot create VMs from machine images.
Number of VMs. You can create up to 5,000 VMs with each call. Also, you can create a maximum of 8,000 instances simultaneously at any time. This simultaneous operation limit is shared between
instances.insert
andinstances.bulkInsert
.Sole-tenant nodes. You cannot create VMs that use sole-tenant node affinity labels.
VM properties. All VM properties, except their names and custom hostnames, must be identical. You cannot use VM properties that are mutually exclusive between VMs, which include but are not limited to static external IP addresses and static internal IP addresses.
Audit logs
Compute Engine logs information about the bulk VM creation to the Admin Activity audit log when you make the API call and when the API call completes.
Compute Engine also creates separate audit logs for each VM. You can
find the audit log for a single VM by matching the value of
protoPayload.resourceName
with the VM name generated by the naming pattern
that you specify with the request.
Pricing
There are no additional charges for using bulk VM creation. As with creating single VMs, billing begins when you create the VMs.
You are not billed for any VMs that Compute Engine fails to create.