Managing autoscalers Stay organized with collections Save and categorize content based on your preferences.
If you usemanaged instance groups (MIGs),read this document to learn how to create, configure, and delete your MIG'sautoscaler.
Before you begin
- If you haven't already, set upauthentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.- Set a default region and zone.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.For more information, seeAuthenticate for using REST in the Google Cloud authentication documentation.
Creating an autoscaler
Creating an autoscaler is slightly different depending on which autoscalingpolicy you want to use. For instructions on creating an autoscaler, see:
- Scaling based on CPU utilization
- Scaling based on load balancing serving capacity
- Scaling based on Cloud Monitoring metrics
- Scaling based on schedules
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.geton the projectcompute.instanceGroupManagers.geton the instance group
Console
- In the Google Cloud console, go to theInstance groups page.
- Click the name of a MIG from the list to open that group's overview page.
- 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.geton the projectcompute.autoscalers.updateon the projectcompute.instanceGroupManagers.useon the project
Console
- In the Google Cloud console, go to theInstance groups page.
- Click the name of a MIG from the list to open that group's overview page.
- ClickEdit.
- ClickGroup size & autoscaling to view and update the group'sautoscaling settings.
- 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 to
OFF.
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.
recommendedSizeproperty of anautoscaler orregionAutoscalerresource.Permissions required for this task
To perform this task, you must have the followingpermissions:
compute.autoscalers.geton the projectcompute.autoscalers.updateon the projectcompute.instanceGroupManagers.useon the project
Console
- In the Google Cloud console, go to theInstance groups page.
- Click the name of a MIG from the list to open that group's overview page.
- ClickEdit.
- ClickGroup size & autoscaling to view and update the group'sautoscaling settings.
- In theAutoscaling section, set theAutoscaling mode to disableor restrict autoscaling for the group, or to turn the autoscaler back on.
- 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:offto disable the autoscaler but maintain its configurationonly-scale-outto restrict the autoscaler to adding VM instances onlyonto 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:OFFto disable the autoscaler but maintain its configurationONLY_SCALE_OUTto restrict the autoscaler to adding instances onlyONto 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's
targetSizevalue 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 the
autoscalingPolicy.maxNumReplicasfield to a lower value thanthe group's currenttargetSizevalue 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. - The
autoscalers.statusfield 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's
targetSizevalue 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. The
minNumReplicasandmaxNumReplicasvalues 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.
- The
autoscalers.statusfield 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.createon the project to create an autoscaler.compute.autoscalers.updateon the project to update an autoscaler.compute.instanceGroupManagers.useon the project.
Console
To configure scale-in controls for an autoscaled MIG:
In the Google Cloud console, go to theInstance groups page.
Click the name of an autoscaled MIG from the list to open that group'soverview page.
ClickEdit.
ClickGroup size & autoscaling to view and update the group'sautoscaling settings.
In theScale-in controls section, selectEnable scale-in controls.
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.
In theOver the course of section, specify how often instances can beremoved from the group.
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)
- Take
max-scaled-in-replicas(for example, 10 VMs) - Set the lower bound of the recommended size to: peak size minus
max-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/ZONEwithregions/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 of60and3600; 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)
- Take
max-scaled-in-replicas(for example, 10 VMs) - Set the lower bound of the recommended size to: peak size minus
max-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:
In the Google Cloud console, go to theInstance groups page.
Click the name of an autoscaled MIG from the list to open that group'soverview page.
ClickEdit.
ClickGroup size & autoscaling to view and update the group'sautoscaling settings.
In theScale-in controls section, clear theEnable scale-in controls checkbox.
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:
AUTOSCALER_NAME: the name of the autoscaler toupdate. To get a list of existing autoscalers and their target MIGs, usetheautoscalers.aggregatedListmethod.
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.deleteon the project
Console
In the Google Cloud console, go to theInstance groups page.
Click the name of a MIG from the list to open that group's overview page.
ClickEdit.
ClickGroup size & autoscaling to view and update the group'sautoscaling settings.
In theAutoscaling mode list, selectDelete autoscaling configuration to stop the autoscaler and deleteits configuration.
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
- Learnhow autoscalers make decisions.
- Learn how to usemultiple autoscaling signalsto scale your group.
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.