About instance flexibility in MIGs Stay organized with collections Save and categorize content based on your preferences.
Instance flexibility in managed instance groups (MIGs) lets you specify multiplemachine types for the virtual machine (VM) instances in the group, rather thanbeing limited to a single machine type. If a machine type is unavailable, theMIG can automatically select another compatible type from your list based on thecurrent resource availability. This flexibility helps to improve resourceobtainability, particularly for applications that can operate on differentmachine types and that require large-scale capacity or hardware with highdemand.
This document describes how instance flexibility works in aMIG and its limitations. To know how to configure a MIG to use instanceflexibility, seeAdd instance flexibility.
Instance flexibility
A MIG creates all its VMs based on theinstance templatethat you select. The instance template specifies the machine type to use foreach VM. With instance flexibility, you can list all the machine types that arecompatible with your application.
The following image compares a MIG that uses a single machinetype with a MIG that uses instance flexibility. As depicted in the image, a MIGwith a single machine type creates identical VMs based on an instance template,whereas a MIG with instance flexibility can create VMs with different machinetypes and sizes.
How instance flexibility works
By default, a MIG creates all VMs using a single machine type from the instancetemplate. You can set multiple machine types in a MIG by configuring an instanceselection (instanceSelections) in theinstance flexibility policy(instanceFlexibilityPolicy).
instanceSelections.machineTypes field overrides themachineTypefield in your instance template. If you want to use the machine type defined inyour instance template, you must list that machine type in theinstanceSelections.machineTypes field.If your workload can operate on a number of different machine types, you canconfigure just a list of all machine types compatible with your application ina singleinstanceSelection as follows:
"instanceFlexibilityPolicy": { "instanceSelections": { "instance-selection-1": { "machineTypes": ["c3-standard-8","n2-standard-8","c2-standard-8"] } } }The machine types within an instance selection have equal preference. If youwant a MIG to choose machine types in a specific order, you can configuremultiple instance selections, each with a list of machine types and a rank todefine preference. A lower value of rank means higher preference. The MIGattempts to create its VMs using machine types with a higher preference. Ifthese preferred machine types are not available, the MIG uses a machine typewith a lower preference.
"instanceFlexibilityPolicy": { "instanceSelections": { "most-preferred": { "rank": 1, "machineTypes": ["c3-standard-16","n2-standard-16","c2-standard-16"] }, "least-preferred": { "rank": 2, "machineTypes": ["c3-standard-8","n2-standard-8","c2-standard-8"] } } }Your application needs to be ready to run on any of listed machine types as the availability of hardware changes over time and specific hardware is not assured unless you usereservations.
How a MIG selects machine types
When you configure multiple machine types, the MIG selects a machine type basedon current resource availability and prioritizes unused reservations. If you'veconfigured ranks, the MIG first considers your preference order. Within a rankedinstance selection, the MIG then checks resource availability, followed byreservations.
The zones in the MIG's region might also impact the machine type selectionbecause resource availability varies across zones. For more information, see thefollowing section about how a MIG selects zones.
How a MIG selects zones
You can configure instance flexibility in a regional MIG that has aBALANCED,ANY, orANY_SINGLE_ZONE target distribution shape. Instance flexibilitydoesn't supportEVEN target distribution shape.
With instance flexibility, when a regional MIG creates a VM, the MIG selects azone depending on the selected target distribution shape as follows:
BALANCED: The MIG selects a zone with available resources that can balancethe VM distribution across zones as evenly as possible. Within a selectedzone, the MIG prioritizes machine types based on ranks, if configured, andavailable reservations.ANY: The MIG selects a zone with available resources and reservations. Ifranks are configured, then the MIG prioritizes the zone in which a machinetype based on ranks is available.ANY_SINGLE_ZONE: The MIG selects a zone which has the most machinetypes based on the ranks, if configured, and where the MIG can create most VMsout of unused reservations.
For more information about how a target distribution shape works, seeRegional MIG target distribution shape.
Instance flexibility and reservations
You can use instance flexibility with reservations. A MIG uses reservationsbased on thereservationAffinity field that you set in the instance template.
When there are multiple machine types in an instance selection, the MIG selectsthe machine type with unused reservation first. If you want to change the orderin which the MIG selects machine types, you can configure multiple instanceselections and specify your preference using ranks. The MIG then first followsthe preference order and then considers reservations within an instanceselection.
For more information about reservations, seeChoose a reservation type.
Instance flexibility and Spot VMs
If your MIG with instance flexibility uses Spot VMs, then the MIGautomatically selects a machine type with the lowest observed preemption rate toensure least disruption for your workload. If you want to override thisbehavior, you can configure multiple instance selections and specify yourpreference using ranks. The MIG then first follows the preference order and thenconsiders the Spot VMs reliability within an instance selection.
For more information about Spot VMs, seeSpot VMs in a managed instance group.
Instance flexibility and VM repairs
By default, if a VM in a MIG fails, the MIG repairs the VM by recreating itusing the same configuration, including the machine type. If you configureinstance flexibility and the original machine type of the failed VM istemporarily unavailable, the MIG selects another machine type based on thespecified instance selection.
For more information about repairs, seeAbout repairing VMs for high availability.
Use cases
The following sections describe some use cases of instance flexibility in MIGs.
Optimize costs
A MIG can automatically provision the most cost-effective instances for yourinfrastructure when you configure the instance flexibility settings of your MIGas follows:
Machine types: Select the machine types that offer the preferredcost-performance ratio for your workload. You don't need to specify all theavailable sizes of each machine type; specify only the sizes that are mostcost-optimal for your needs.
Rank: Assign ranks to instance selections according to your costpreferences, with the lowest-cost machine type as most preferred. This helpsto ensure that you obtain the lowest-cost machine type based onavailability.
Location: When creating the MIG, select all zones and the
ANYtargetdistribution shape. This increases the chances of obtaining the lowest-costmachine types in zones where they are available.
Based on your instance flexibility settings, the MIG automatically provisionsthe best possible combination of available machine types to meet your costcriteria and the total capacity requested. This ensures the lowest possible costat a given time.
Improve obtainability
You can configure MIG instance flexibility to improve obtainability. To do so,select as many machine types as possible that are compatible with yourapplication within the same rank. You can further increase the chance ofobtaining the resources by choosing all zones when creating your MIG and usingtheANY target distribution shape, which prioritizes zones whereresources are available. Based on the selected machine types and theANYshape, the MIG finds capacity where it is most available.
To maximize the chances of acquiring Spot VMs and to reduce thechances of preemption, Google recommends you include a wide range of machinetypes within the same rank. This widens the MIG's search for availablecapacity, leading to the best possible outcomes with the spot provisioningmodel.
Maximize performance
You can configure MIG instance flexibility to maximize performance. To do so,select machine families and sizes that best serve your workload. Then rank themachine types based on performance, from highest to lowest, using the mostpreferred size within each family. Based on the ranking and the machine types,the MIG selects the highest-performing machines from all available resources.
Limitations
Instance flexibility has the following limitations:
Instance flexibility is not supported in zonal MIGs. You can use a regionalMIG with a single zone instead.
Instance flexibility doesn't support the following MIG features:
- Regional MIGs withtarget distribution shape set to
EVEN - Autoscaling
- Automatic updating of VM configuration andcanary updates(two instance templates)
- Updates on repairs
- Suspending or stopping VMs
- Resize requests that create GPU VMs all at once
- Regional MIGs withtarget distribution shape set to
When using a MIG withCloud Load Balancing,use machine types with similar performance—for example, the same vCPU count—toprevent over-utilization of smaller hardware and under-utilization of fastermachines. Otherwise, load balancing might not work effectively when usingmachine types with different performance.
What's next?
- Learn more aboutdifferent machine types.
- Add instance flexibilityto a MIG.
- View instance flexibilityin a MIG.
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-16 UTC.