About instance flexibility for VMs created in bulk

This document describes instance flexibility when creating VMs in bulk using Compute Engine.

When you create virtual machines (VMs) in bulk in a region, if your application is not restricted to a single machine type, you can increase the success rate of provisioning your required number of VMs by configuring instance flexibility. Instance flexibility lets you specify one or more machine types that are suitable for your workload. Compute Engine then provisions VMs using any of these machine types, based on capacity and quota availability.

Use instance flexibility

To configure instance flexibility, you list suitable machine types by defining one or more instance selections in your regional bulk insert request. For example, in a REST request, you include the instanceFlexibilityPolicy object, within which you define one or more instanceSelections objects, each containing a list of machine types.

When Compute Engine receives the request, it first validates the machine types and their zonal compatibility, excluding any invalid entries. If at least one valid configuration exists, the operation proceeds.

Compute Engine then attempts to provision VMs based on available hardware, quota, and reservations. If you configure ranks for your instance selections, it prioritizes selections with a lower rank. Within each rank, Compute Engine considers unused reservations and Spot VM guidance to select machine types with a lower probability of preemption.

Zone selection when a target distribution shape is defined

When using instance flexibility with a regional bulkInsert request, you can specify a target distribution shape to control how VMs are distributed across zones in the region. Compute Engine selects zones for provisioning VMs based on this shape, as follows:

  • ANY_SINGLE_ZONE: Compute Engine selects a single zone that has the most capacity for machine types with a higher preference.
  • BALANCED: Compute Engine distributes VMs as evenly as possible across zones with available resources. Within each zone, Compute Engine prioritizes machine types with a higher preference.
  • ANY: Compute Engine selects zones with available resources. If ranks are configured, then Compute Engine prioritizes zones to provision VMs with machine types with a higher preference.

For more information, see Create VMs in bulk in a region.

Minimum VM provisioning and instance flexibility

If you define a value for the minimum required number of VMs (minCount) in the bulkInsert request, the API attempts to create at least that many VMs. If Compute Engine can't provision the minimum required number of VMs (minCount), the entire operation fails, and Compute Engine doesn't create any VMs. When you use minCount with instance flexibility, Compute Engine prioritizes provisioning VMs based on obtainability over rank, as follows:

  • Compute Engine prioritizes provisioning the maximum number of VMs up to count, even if this means using machines of lower preference. For example, if your request specifies a minimum of one required VM (minCount=1) and a maximum of 10 VMs (count=10), and if Compute Engine has capacity to provision either one higher-preference VM or six lower-preference VMs, then Compute Engine provisions the six lower-preference VMs.
  • If Compute Engine can provision the same maximum number of VMs up to count by using different instance selections, it prioritizes the selection with higher preference. For example, if your request specifies a minimum of one required VM (minCount=1) and a maximum of 10 VMs (count=10), and if Compute Engine can provision six VMs by using either a higher-preference or a lower-preference instance selection, then Compute Engine provisions the six VMs from the higher-preference selection.

For more information, see minCount property in bulkInsert.

Bulk insert validation and error scenarios

Compute Engine performs an initial validation of machine types and their zonal compatibility, excluding any invalid entries from consideration. If at least one valid configuration remains after this initial check, Compute Engine proceeds with VM creation.

However, some validations of your configuration can occur only after Compute Engine has selected the zones and machine types to use for provisioning, based on your instance flexibility policy and available capacity. If, during this later validation stage, the specific machine type and zone combination chosen for provisioning is found to be invalid, the entire bulk insert request fails with validation errors. This failure can happen even if other configurations within the instanceFlexibilityPolicy were initially valid.

Limitations

The following limitations apply when you use instance flexibility for bulk VM creation:

  • You can specify instance flexibility only for regional bulkInsert requests; you can't use it with zonal requests.
  • Instance flexibility doesn't support AI Hypercomputer features, including future reservations, the flex start provisioning model, and A3 Ultra, A4, and newer GPUs.
  • You can't specify custom machine types with instance flexibility.
  • You can specify a maximum of 10 different machine types across a maximum of 10 different instance selections.

What's next