Managing autoscalers

If you usemanaged instance groups (MIGs),read this document to learn how to create, configure, and delete your MIG'sautoscaler.

Before you begin

Creating an autoscaler

Creating an autoscaler is slightly different depending on which autoscalingpolicy you want to use. For instructions on creating an autoscaler, see:

Getting information about an autoscaler

To get more information about a particular autoscaler, use the console, thegcloud compute instance-groups managed describesub-command, or theget method for azonal orregionalautoscaler REST resource.

Permissions required for this task

To perform this task, you must have the followingpermissions:

  • compute.autoscalers.get on the project
  • compute.instanceGroupManagers.get on the instance group

Console

  1. In the Google Cloud console, go to theInstance groups page.

    Go to Instance groups

  2. Click the name of a MIG from the list to open that group's overview page.
  3. ClickDetails to view the group's details, including its autoscalingsettings.

gcloud

Use theinstance-groups managed describe command:

gcloud compute instance-groups managed describeINSTANCE_GROUP_NAME

If an autoscaler is attached to the group, the command returns details aboutthe autoscaler:

...autoscaler:  autoscalingPolicy:    coolDownPeriodSec: 60    cpuUtilization:      utilizationTarget: 0.6    maxNumReplicas: 20    minNumReplicas: 10    mode: ON    scaleInControl:      timeWindowSec: 300      maxScaledInReplicas:        fixed: 3        calculated: 3...

REST

Use theinstanceGroupManagers.get method.For a regional MIG, replacezones/ZONE withregions/REGION.

GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instanceGroupManagers/INSTANCE_GROUP_NAME

If an autoscaler is attached to the group, the request returns a link tothe autoscaler resource.

200 OK{  ...  "status": {    ...    "autoscaler": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-c/autoscalers/example-group"  },}

To retrieve details about the autoscaler resource, use theautoscalers.get methodfor a zonal MIG or theregionAutoscalers.get methodfor a regional MIG.

GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/autoscalers/example-autoscaler
200 OK{ "kind": "compute#autoscaler", "id": "8744945839459481093", "creationTimestamp": "2018-09-28T13:02:50.553-07:00", "name": "example-group", "target": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-c/instanceGroupManagers/example-group", "autoscalingPolicy": {  "minNumReplicas": 10,  "maxNumReplicas": 20,  "mode": "ON",  "scaleInControl": {    "timeWindowSec": 60,    "maxScaledInReplicas": {      "calculated": 3,      "percent": 15    }  },  "coolDownPeriodSec": 60,  "cpuUtilization": {   "utilizationTarget": 0.6  } }, "zone": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-c", "selfLink": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-c/autoscalers/example-group", "status": "ACTIVE"}

Updating an autoscaler

When you update an autoscaler, it might take some time for the changes topropagate, and it might be a couple of minutes before your new autoscalersettings are reflected.

Permissions required for this task

To perform this task, you must have the followingpermissions:

  • compute.autoscalers.get on the project
  • compute.autoscalers.update on the project
  • compute.instanceGroupManagers.use on the project

Console

  1. In the Google Cloud console, go to theInstance groups page.

    Go to Instance groups

  2. Click the name of a MIG from the list to open that group's overview page.
  3. ClickEdit.
  4. ClickGroup size & autoscaling to view and update the group'sautoscaling settings.
  5. ClickSave when you are done.

gcloud

Use theupdate-autoscaling command.

gcloud compute instance-groups managed update-autoscalingINSTANCE_GROUP_NAME \        --max-num-replicasMAX_NUM ...

For instructions on how to create an autoscaler, seeCreating an autoscaler.

REST

To update an autoscaler resource, use theautoscalers.patch methodfor a zonal MIG orregionAutoscalers.patch methodfor a regional MIG.Provide a request body that contains the new configuration.

PATCH https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-f/autoscalers/example-autoscaler{ "autoscalingPolicy": {  "maxNumReplicas": 20 }}
200 OK{ "kind": "compute#operation", "id": "4244494732310423322", "name": "operation-1556912627871-58800f8216ed7-74ab1720-7d360603", "zone": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-f", "operationType": "compute.autoscalers.patch", "targetLink": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-f/autoscalers/example-autoscaler", "targetId": "340775527929467142", "status": "RUNNING", ...}

When you perform any requests that modify data, azoneOperations orregionOperations resourceis returned, and you can query the operation to check the status of yourchange.

Using predictive autoscaling

Predictive autoscaling uses historical data to scale out your group aheadof anticipated load. It works best if your workload meets the followingcriteria:

  • Your application takes a long time to initialize—for example, if you configureaninitialization period of morethan 2 minutes.
  • Your workload varies predictably with daily or weekly cycles.

For more information, seeScaling based on predictions.

Turning off or restricting an autoscaler

Turn off an autoscaler to temporarily prevent it from scaling your MIG, orrestrict your autoscaler so that it can only scale out your MIG. This feature isuseful when you want to:

  • Investigate VM instances without interference from scaling in.
  • Reconfigure multiple properties of your MIG withoutscaling actions being triggered while your group is only partiallyreconfigured.
  • Maintain MIG capacity for a fast rollback while redirecting aworkload to a new MIG.
  • Enablepredictive autoscalinglater. Predictive autoscaling requires an autoscaling policy in order to startgathering load history on which to base predictions. The autoscaler detectsthis history even when its mode is set toOFF.

If and when you re-enable the autoscaler, the autoscaler automatically returnsto normal operation.

Use the instructions provided in this section to setthe autoscaler's mode. The following modes are available:

  • Off: Temporarily disables autoscaling. Use this mode to preventautomatic changes of the MIG's size. The autoscaling configurationremains intact so you can re-enable autoscaling later.
  • Only scale out: Restrict autoscaling only to adding new VM instances. Usethis mode to protect the group from shrinking and allow the group to provisionextra VMs when load increases.
  • On: Enables all autoscaling operations per its policy.
Note: The autoscaler calculates the recommended group size regardless of itsmode. You can check the recommended size by reading therecommendedSizeproperty of anautoscaler orregionAutoscalerresource.

Permissions required for this task

To perform this task, you must have the followingpermissions:

  • compute.autoscalers.get on the project
  • compute.autoscalers.update on the project
  • compute.instanceGroupManagers.use on the project

Console

  1. In the Google Cloud console, go to theInstance groups page.

    Go to Instance groups

  2. Click the name of a MIG from the list to open that group's overview page.
  3. ClickEdit.
  4. ClickGroup size & autoscaling to view and update the group'sautoscaling settings.
  5. In theAutoscaling section, set theAutoscaling mode to disableor restrict autoscaling for the group, or to turn the autoscaler back on.
  6. ClickSave when you are done.

gcloud

To disable, restrict, or re-enable an autoscaler, use theupdate-autoscaling command with the--mode flag.

gcloud compute instance-groups managed update-autoscalingINSTANCE_GROUP_NAME \        --modeMODE

Replace the following:

  • MODE:
    • off to disable the autoscaler but maintain its configuration
    • only-scale-out to restrict the autoscaler to adding VM instances only
    • on to re-enable all autoscaler activities according to its policy

REST

To update the mode of an autoscaler resource, use theautoscalers.patch methodfor a zonal MIG or theregionAutoscalers.patch methodfor a regional MIG.Provide a request body that includes theautoscalingPolicy.modeproperty.

PATCH https://compute.googleapis.com/compute/v1/projects/my-project/regions/us-central1-f/autoscalers?autoscaler=my-autoscaler{  "autoscalingPolicy": {    "mode":"MODE"  }}

Replace the following:

  • MODE:
    • OFF to disable the autoscaler but maintain its configuration
    • ONLY_SCALE_OUT to restrict the autoscaler to adding instances only
    • ON to re-enable all autoscaler activities according to its policy

When you set the autoscaling mode toONLY_SCALE_OUT, the autoscaler behaves asfollows:

  • The autoscaler does not decrease the MIG'stargetSize value regardless ofdecreases in load or changes to the autoscaler configuration.
  • If you manually change the target size of a zonal MIG, the autoscaleroverrides your manually provided size if it is smaller than the autoscaler'srecommended size.
  • You cannot manually change the target size of a regional MIG.
  • If you set theautoscalingPolicy.maxNumReplicas field to a lower value thanthe group's currenttargetSize value while the autoscaler's mode is set toONLY_SCALE_OUT, the autoscaler does not reduce the number of instances inthe group. As usual, the autoscaler continuously recomputes the group'srecommended size and might decrease the group's recommended size to complywith the new maximum, but the group is not scaled in.
  • Theautoscalers.status field reports a warning: "Autoscaling operates in arestricted mode: ONLY_SCALE_OUT."

When you set the autoscaler's mode toOFF, the autoscaler behaves as follows:

  • The autoscaler does not change the MIG'stargetSize value in response tochanges in load or in autoscaler configuration. As usual, the autoscalercontinuously recomputes the group's recommended size and might decrease thegroup's recommended size to comply with the new maximum, but the group is notscaled in.
  • You can manually change the target size of a zonal or a regional MIG. TheminNumReplicas andmaxNumReplicas values of the autoscaling policy do notaffect the size you set.
  • If you turn off autoscaling for a regional MIG in whichproactive instance redistributionis enabled, and if the MIG has an uneven distribution of instances acrosszones, then the group proactively deletes or creates instances in its zones toreestablish an even distribution.
  • Theautoscalers.status field reports a warning: "Autoscaling operates in arestricted mode: OFF."

Controlling the scale-in rate of an autoscaler

If your workloads take many minutes to initialize, configurescale-in controls toreduce the risk of response latency and outages due to abrupt scale-in events.Specifically, if you routinely expect a load spike to follow soon after adecline in load, you can limit the scale-in rate. Limiting the scale-in rateprevents the autoscaler from reducing a MIG's size by more VM instances thanyour workload can tolerate to lose.

Configuring scale-in controls

Configuring scale-in controls is optional. By default, scale-in controls are notconfigured. When not configured, the autoscaler still relies on its defaultstabilization mechanism.That is, it maintains the recommended size at a level required to serve peakload, observed during the stabilization period.

Permissions required for this task

To perform this task, you must have the followingpermissions:

  • compute.autoscalers.create on the project to create an autoscaler.
  • compute.autoscalers.update on the project to update an autoscaler.
  • compute.instanceGroupManagers.use on the project.

Console

To configure scale-in controls for an autoscaled MIG:

  1. In the Google Cloud console, go to theInstance groups page.

    Go to Instance groups

  2. Click the name of an autoscaled MIG from the list to open that group'soverview page.

  3. ClickEdit.

  4. ClickGroup size & autoscaling to view and update the group'sautoscaling settings.

  5. In theScale-in controls section, selectEnable scale-in controls.

  6. In theDon't scale in by more than field, specify the maximum numberor percent of instances that can be removed from the group at a time.

  7. In theOver the course of section, specify how often instances can beremoved from the group.

  8. ClickSave.

gcloud

You can configure scale-in controls when creating an autoscaler or whenupdating an autoscaler.

Configuring scale-in controls when creating an autoscaler

Set scale-in controls when creating an autoscaler for a MIG byusing the--scale-in-control flag with thegcloudcompute instance-groups managed set-autoscalingcommand.For example, use the following command to configure autoscaling for anexample-group:

gcloud compute instance-groups managed set-autoscalingINSTANCE_GROUP_NAME \    --target-cpu-utilization 0.6 \    --max-num-replicas 50 \    --scale-in-control max-scaled-in-replicas=MAX_SCALE_IN_REPLICAS,time-window=TIME_WINDOW

Configuring scale-in controls when updating an autoscaler

Update scale-in controls in a MIG's existing autoscalerby using the--scale-in-control flag with thegcloud compute instance-groups managed update-autoscalingcommand.For example, use the following command to set scale-in controls in anexisting autoscaling configuration forexample-group:

gcloud compute instance-groups managed update-autoscalingINSTANCE_GROUP_NAME \    --scale-in-control max-scaled-in-replicas=MAX_SCALE_IN_REPLICAS,time-window=TIME_WINDOW

Replace the following:

  • INSTANCE_GROUP_NAME: the name of the MIG toupdate.
  • MAX_SCALE_IN_REPLICAS: the maximum number ofVMs allowed to be deducted from the peak size, taken fromthe specified trailing time window. The specified number of VM instancescan be scaled in all at once, so your service should be able to affordlosing this many VMs all at once. You can specify either a number of VMsor a percentage. Use the% sign for percentages; for example:50%.
  • TIME_WINDOW: trailing time window to take thepeak size from. Autoscaling won't scale in by more thanthe maximum allowed number of replicas from the peak sizetaken during this trailing time window. Specify this value in secondswithin a [60, 3600] interval.

For example, say you set the time window to 1800 seconds (30 minutes).When calculating the current recommended size for the MIG, the autoscaleruses the following logic:

  • Take the peak size from the last 30 minutes (for example, 100 VMs)
  • Takemax-scaled-in-replicas (for example, 10 VMs)
  • Set the lower bound of the recommended size to: peak size minusmax-scaled-in-replicas (100 - 10 = 90 VMs)

REST

Configure scale-in controls by setting themaxScaledInReplicasandtimeWindowSec fields within theautoscalingPolicy.scaleInControlstructure in azonal orregionalautoscaler resource. There are no default values for these fields, you mustprovide values for both fields.

You can configure scale-in controls when creating an autoscaler or whenupdating an autoscaler.

Configuring scale-in controls when creating an autoscaler

For a zonal MIG, use theautoscalers.insert method.For a regional MIG, use theregionAutoscalers.insert method.

POSThttps://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/autoscalers{  "name": "AUTOSCALER_NAME",  "target": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceGroupManagers/INSTANCE_GROUP_NAME",  "autoscalingPolicy": {    "minNumReplicas": 1,    "maxNumReplicas": 5,    "coolDownPeriodSec": 60,    "cpuUtilization": {      "utilizationTarget": 0.8    },"scaleInControl": {      "maxScaledInReplicas": {           "fixed":MAX_SCALE_IN_REPLICAS      },      "timeWindowSec":TIME_WINDOW    }  }}

For more information about creating an autoscaler, refer to the followingarticles:

Configuring scale-in controls when updating an autoscaler

For a zonal MIG, use theautoscalers.patch method.For a regional MIG, use theregionAutoscalers.patch method.

PATCHhttps://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/autoscalers?autoscaler=AUTOSCALER_NAME{  "autoscalingPolicy": {    "minNumReplicas": 1,    "maxNumReplicas": 5,    "coolDownPeriodSec": 60,    "cpuUtilization": {      "utilizationTarget": 0.8    },"scaleInControl": {      "maxScaledInReplicas": {           "fixed":MAX_SCALE_IN_REPLICAS      },      "timeWindowSec":TIME_WINDOW    }  }}

Replace the following:

  • AUTOSCALER_NAME: the name of the autoscaler tocreate. You can name your autoscaler after the MIG that will use it orname it something else.
  • INSTANCE_GROUP_NAME: the name of the MIG toadd the autoscaler to. For a regional MIG, replacezones/ZONE withregions/REGION.
  • MAX_SCALE_IN_REPLICAS: the maximum number ofVMs allowed to be deducted from the peak recommended target size, takenfrom the specified trailing time window. The specified number of VMinstances can be scaled in all at once, so your service should be ableto afford to lose this many VMs all at once. You can specify either anumber of VMs or a percentage. Use themaxScaledInReplicas.percentageto specify a percent value.
  • TIME_WINDOW: the trailing time window to takethe peak recommended size from. Autoscaling won't scale in by more thanthe maximum allowed number of replicas from the peak recommended sizetaken during this trailing time window. Specify this value in secondswithin the range of60 and3600; for example:1800.

For example, say you set the time window to 1800 seconds (30 minutes).When calculating the current recommended size for the MIG, the autoscaleruses the following logic:

  • Take the peak size from the last 30 minutes (for example, 100 VMs)
  • Takemax-scaled-in-replicas (for example, 10 VMs)
  • Set the lower bound of the recommended size to: peak size minusmax-scaled-in-replicas (100 - 10 = 90 VMs)

For more information about how scale-in controls work, seeUnderstanding autoscaler decisions.

Getting current configuration of scale-in controls

To get the current configuration of scale-in controls, seeGetting information about an autoscaler.

Removing scale-in controls

You can remove scale-in controls to lift restrictions on the timing andmagnitude of scale-in operations using the Google Cloud CLI or theCompute Engine API.

Without scale-in controls, the autoscaler still relies on its defaultstabilization mechanism. Specifically, it maintains a recommended size at alevel required to serve peak load, observed during thestabilization period.

Console

To remove scale-in controls for an autoscaled MIG:

  1. In the Google Cloud console, go to theInstance groups page.

    Go to Instance groups

  2. Click the name of an autoscaled MIG from the list to open that group'soverview page.

  3. ClickEdit.

  4. ClickGroup size & autoscaling to view and update the group'sautoscaling settings.

  5. In theScale-in controls section, clear theEnable scale-in controls checkbox.

  6. ClickSave.

gcloud

Remove scale-in controls by using the--clear-scale-in-control flag withthegcloud compute instance-groups managed update-autoscalingcommand.For example, use the following command to remove scale-in controls fromthe autoscaling configuration forexample-group:

gcloud compute instance-groups managed update-autoscaling example-group \    --clear-scale-in-control

REST

To remove scale-in controls, use theautoscalers.patch method for a zonal MIG or use theregionAutoscalers.patch methodfor a regional MIG,and provide empty configuration for scale-in controls.

PATCHhttps://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/autoscalers?autoscaler=AUTOSCALER_NAME{  "autoscalingPolicy": {    "scaleInControl": null  }}

Replace the following:

Deleting an autoscaler

You can permanently delete your autoscaler resource, and its history.If you want to temporarily stop autoscaling and keep your autoscaler resourceand its configuration and history,disableyour autoscaler instead.

Permissions required for this task

To perform this task, you must have the followingpermissions:

  • compute.autoscalers.delete on the project

Console

  1. In the Google Cloud console, go to theInstance groups page.

    Go to Instance groups

  2. Click the name of a MIG from the list to open that group's overview page.

  3. ClickEdit.

  4. ClickGroup size & autoscaling to view and update the group'sautoscaling settings.

  5. In theAutoscaling mode list, selectDelete autoscaling configuration to stop the autoscaler and deleteits configuration.

  6. ClickSave when you are done.

gcloud

Use thestop-autoscaling command to stop an autoscaler and delete its configuration.

gcloud compute instance-groups managed stop-autoscalingINSTANCE_GROUP_NAME

Stopping an autoscaler deletes it from the MIG. If you want to restart the autoscaler, you must recreate it by using theset-autoscaling command.

If you delete a MIG using the gcloud CLI, any autoscalers attached to the MIG are also deleted.

REST

To stop an autoscaler and delete its configuration, use theautoscalers.delete method for a zonal MIG or use theregionAutoscalers.delete method for a regional MIG.

 DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/autoscalers/AUTOSCALER_NAME

Feedback

We want to learn about your use cases, challenges, and feedback aboutautoscaling. Share your feedback with our team atmig-discuss@google.com.

What's next

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 2026-02-18 UTC.