Scaling based on schedules Stay organized with collections Save and categorize content based on your preferences.
Schedule-based autoscaling lets you improve the availability of yourworkloads by scheduling capacity ahead of anticipated load.If you run your workload on a managed instance group (MIG), you can schedule arequired number of virtual machine (VM) instances for recurring loadpatterns as well as one-off events. Use scaling schedules if your workloadtakes a long time to initialize and you want to scale out in advance ofanticipated load spikes.
This document describes how you can create, list, edit, disable, re-enable, anddelete scaling schedules for an existing MIG. For moreinformation about MIGs and autoscaling, seeCreating managed instance groupsandAutoscaling groups of instances.
Before you begin
- Read about autoscalerfundamentals.
- 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.
Terraform
To use the Terraform samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
Install the Google Cloud CLI.
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.If you're using a local shell, then create local authentication credentials for your user account:
gcloudauthapplication-defaultlogin
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
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.
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.
Limitations
Scaling schedules are restricted by thelimitations for all autoscalersas well as the following limitations:
- You can have up to 128 scaling schedules per MIG. To mitigate this limit,delete scaling schedules that have an
OBSOLETEstatus and that you don't plan to run again. - The minimum duration for scaling schedules is 5 minutes.
Creating a scaling schedule
You can create up to 128 scaling schedules per MIG. For more information, seeScaling schedule settings.
Note: Consider the following when you create a scaling schedule:- Autoscaler never creates more than the maximum number of VM instances or fewer than the minimum number of VM instances configured in the MIG's autoscaling settings. Make sure the autoscaling settings' maximum lets the autoscaler create the number of VM instances required by each scaling schedule.
- VM instances aren't ready immediately at the given start time. Configure your start time to be early enough for VMs to boot and start your application before they are needed.
- Autoscaler constantly monitors scaling schedules, so any configuration changes are effective immediately. For example, suppose you create a new schedule at 3 PM that runs every day at 2 PM for 3 hours. This schedule becomes active shortly after it is created and remains active until 5 PM.
The following instructions explain how to create a scaling schedule for a MIG.
Permissions required for this task
To perform this task, you must have the followingpermissions:
- To add a scaling schedule to an existing autoscaler:
compute.autoscalers.updateon the project
- To create a new autoscaler with a scaling schedule for an existing MIG:
compute.autoscalers.createon the projectcompute.instanceGroupManagers.useon the MIG
Console
In the Google Cloud console, go to theInstance groups page.
Click the name of a MIG in the list.
ClickEdit.
ClickGroup size & autoscaling to expand the section.
If autoscaling configuration doesn't exist, clickConfigure autoscaling.
By default, the autoscaling configuration adds a signal based onCPUutilization. If you want to scale your MIG based only on schedules,delete the default CPU utilization metric after you add the schedules.
In theAutoscaling schedules section, clickManage.
In theScaling schedules pane, for each scaling schedule that youwant to add, do the following:
- ClickCreate schedule.
- In theCreate scaling schedule pane, enter aName.
- Optional: Enter aDescription.
- Enter the number ofMinimum required instances thatthis schedule provides when it is active.
To specify the start time and recurrence of your scaling schedule, youcan use the default interface. You can also configure a schedule witha more complex start time and recurrence using thecron expression. Depending on how you want toconfigure, follow these steps:
Default interface
In theStart time field, enter a start time in theformat
HH:MM AM/PM—for example,09:00 AM.Click theTime zone field. Select a country, and then atime zone.
You can use theSearch by country field to find a countryor a time zone. For example, type
Note: Some locations observe daylight saving time (DST).For more information, seeTime zones.Australia/australian centralto find the Central StandardTime zones in Australia.In theDuration andUnit of time fields, enter aduration and select a corresponding unit of time.
In theRecurrence field, select how often the schedulerepeats.
You can chooseOnce orEvery day. To specify that theschedule repeats only on certain days, choose eitherEvery week orEvery month. After selecting one ofthese options, use the additional list to select which days ofthe week or month the schedule starts.
Cron expression
To enable, click theUse CRON expression toggle.
In theCRON expression field, enter acron expression that specifies the starttime and recurrence.
Click theTime zone field. Select a country, and then atime zone.
You can use theSearch by country field to find a countryor a time zone. For example, type
Note: Some locations observe daylight saving time (DST).For more information, seeTime zones.Australia/australian centralto find the Central StandardTime zones in Australia.In theDuration andUnit of time fields, enter aduration and select a corresponding unit of time.
ClickSave. TheScaling schedules pane lists the schedule thatyou created.
When you've finished creating schedules, clickDone.
The schedules are saved and applied to your MIG.
ClickSave to exit the edit page.
gcloud
To add a scaling schedule to a MIG that does not have an existingautoscaling policy, use thegcloud compute instance-groups managed set-autoscaling command.
gcloud compute instance-groups managed set-autoscalingMIG_NAME \ [--min-num-replicas=MIN_NUM_REPLICAS] \ --max-num-replicas=MAX_NUM_REPLICAS \ --set-schedule=SCHEDULE_NAME \ --schedule-cron="CRON_EXPRESSION" \ --schedule-duration-sec=DURATION \ [--schedule-time-zone="TIME_ZONE"] \ --schedule-min-required-replicas=MIN_REQ_REPLICAS \ [--schedule-description="DESCRIPTION"] \ [--zone=ZONE | --region=REGION]
To add a scaling schedule to a MIG with an existing autoscaling policy,use thegcloud compute instance-groups managed update-autoscaling command.
gcloud compute instance-groups managed update-autoscalingMIG_NAME \ [--min-num-replicas=MIN_NUM_REPLICAS] \ [--max-num-replicas=MAX_NUM_REPLICAS] \ --set-schedule=SCHEDULE_NAME \ --schedule-cron="CRON_EXPRESSION" \ --schedule-duration-sec=DURATION \ [--schedule-time-zone="TIME_ZONE"] \ --schedule-min-required-replicas=MIN_REQ_REPLICAS \ [--schedule-description="DESCRIPTION"] \ [--zone=ZONE | --region=REGION]
Replace the following:
MIG_NAME: the name of a MIGwith an existing autoscaling policy.MIN_NUM_REPLICAS: Optional: the minimumnumber of instances required for this MIG. Google recommends setting thisvalue to the minimum number of instances that you need when no scalingschedule is active. To scale your MIG to zero instances, set this value to0and make sure that thenecessary conditionsare met.MAX_NUM_REPLICAS: the maximumnumber of instances that can ever be provided for this MIG. Optional fora MIG with an existing autoscaling policy.SCHEDULE_NAME: the name of the newscaling schedule.CRON_EXPRESSION: the start time andrecurrence of this schedule formatted as acron expression.DURATION: theduration, in seconds,that this schedule is active.TIME_ZONE: Optional: theIANA time zone for the schedule's start time—forexample,Europe/Paris. The default value isUTC.MIN_REQ_REPLICAS: the number ofminimum required instances thatthis schedule provides when it is active.DESCRIPTION: Optional: a description of the newscaling schedule.ZONEorREGION: Optional:the zone or region where your MIG is located.
You can create schedules that run once or that periodically repeat.
Repeating schedule
This example command creates a schedule that repeats.This schedule specifies that you want your MIG to contain at least10 VM instances on every Monday, Tuesday, Wednesday, Thursday, andFriday from 8:30 AM to 5 PM Coordinated Universal Time (UTC). This commandalso uses the--min-num-replicas and--max-num-replicas flags to updatethe minimum number of instances to 0 and the maximum number of instancesto 30 for all the autoscaling signals of the selected MIG. This commandassumes you have an existing MIG namedexample-migwith an existing autoscaling policy.
gcloud compute instance-groups managed update-autoscaling example-mig \ --min-num-replicas=0 \ --max-num-replicas=30 \ --set-schedule=workday-capacity \ --schedule-cron="30 8 * * Mon-Fri" \ --schedule-duration-sec=30600 \ --schedule-min-required-replicas=10 \ --schedule-description="Have at least 10 VMs every Monday through Friday from 8:30 AM to 5 PM UTC"
Onetime schedule
This example command creates a schedule that runs once.This schedule specifies that you want your MIG to contain at least30 VM instances all day on January 30, 2030 for theAmerica/New_Yorktime zone. This command assumes you have an existing MIG namedexample-mig that is located inus-east1-b and hasan existing autoscaling policy.
gcloud compute instance-groups managed update-autoscaling example-mig \ --set-schedule=example-onetime-schedule \ --schedule-cron="0 0 30 1 * 2030" \ --schedule-duration-sec=86400 \ --schedule-time-zone="America/New_York" \ --schedule-min-required-replicas=30 \ --schedule-description="Schedule a minimum of 30 VMs all day for January 30, 2030" \ --zone=us-east1-b
Terraform
To add a scaling schedule to a MIG, use thegoogle_compute_autoscaler resource.
resource "google_compute_autoscaler" "default" { provider = google-beta name = "my-autoscaler" zone = "us-central1-f" target = google_compute_instance_group_manager.default.id autoscaling_policy { max_replicas = 5 min_replicas = 1 cooldown_period = 60 scaling_schedules { name = "every-weekday-morning" description = "Increase to 2 every weekday at 7AM for 12 hours." min_required_replicas = 2 schedule = "0 7 * * MON-FRI" time_zone = "America/New_York" duration_sec = 43200 } }}To learn how to apply or remove a Terraform configuration, seeBasic Terraform commands.
REST
Note: By using REST, you can definemultiple scalingschedules in a single call.To create an autoscaler with scaling schedules for a MIG, use theautoscalers.insert methodfor a zonal MIG or theregionAutoscalers.insert methodfor a regional MIG.
Make the following call to create a schedule for a zonal MIG that does nothave an existing autoscaling policy:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/autoscalers/{ "name": "AUTOSCALER_NAME", "target": "https://www.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/instanceGroupManagers/MIG_NAME", "autoscalingPolicy": { "minNumReplicas":MIN_NUM_REPLICAS, "maxNumReplicas":MAX_NUM_REPLICAS, "scalingSchedules": { "SCHEDULE_NAME": { "minRequiredReplicas":MIN_REQ_REPLICAS, "schedule": "CRON_EXPRESSION", "timeZone": "TIME_ZONE", "durationSec":DURATION, "description": "DESCRIPTION" }, ... } }}To create schedules for a MIG that has an existing autoscalingpolicy, use theautoscalers.patch methodfor a zonal MIG or theregionAutoscalers.patch methodfor a regional MIG.
For example, make the following call to create a schedule for a zonal MIGthat has an existing autoscaling policy:
PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/autoscalers?autoscaler=AUTOSCALER_NAME{ "autoscalingPolicy": { "minNumReplicas":MIN_NUM_REPLICAS, "maxNumReplicas":MAX_NUM_REPLICAS, "scalingSchedules": { "SCHEDULE_NAME": { "minRequiredReplicas":MIN_REQ_REPLICAS, "schedule": "CRON_EXPRESSION", "timeZone": "TIME_ZONE", "durationSec":DURATION, "description": "DESCRIPTION" }, ... } }}Replace the following:
PROJECT: yourproject id.ZONE: the zone where your MIG is located.AUTOSCALER_NAME: the name of anexisting autoscaler. This is often the same as the name of the MIG.MIN_NUM_REPLICAS: Optional: the minimumnumber of instances required for this MIG. Googlerecommends setting this value to the minimum number of instances that youneed when no scaling schedule is active. To scale your MIG to zeroinstances, set this value to0and make sure that thenecessary conditionsare met.MAX_NUM_REPLICAS: the maximumnumber of instances that can ever be provided for this MIG. Optional fora MIG with an existing autoscaling policy.SCHEDULE_NAME: the name of the newscaling schedule.MIN_REQ_REPLICAS: theminimum required instances thatthis schedule provides when it is active.CRON_EXPRESSION: the start time andrecurrence of this schedule formatted as acron expression.TIME_ZONE: Optional: theIANA time zone for the schedule's start time—forexample,Europe/Paris. The default value isUTC.DURATION: theduration, in seconds,that this schedule is active.DESCRIPTION: Optional: a description of the newscaling schedule.
You can create schedules that run once or that periodically repeat.
Repeating schedule
This example API call creates a schedule that repeats.This schedule specifies that you want a zonal MIG to containat least 10 VM instances on every Monday, Tuesday, Wednesday, Thursday, andFriday from 8:30 AM to 5 PM Coordinated Universal Time (UTC). This API callalso uses theminNumReplicas andmaxNumReplicas fields to updatethe minimum number of instances to 0 and the maximum number of instancesto 30 for all the autoscaling signals of the selected MIG.This API call assumes that you have an existing projectnamedexample-project with a zonal MIG that is located inus-east1-band has an autoscaler namedexample-autoscaler with anexisting autoscaling policy.
PATCH https://compute.googleapis.com/compute/v1/projects/example-project/zones/us-east1-b/autoscalers?autoscaler=example-autoscaler{ "autoscalingPolicy": { "minNumReplicas": 0, "maxNumReplicas": 30, "scalingSchedules": { "workday-capacity": { "minRequiredReplicas": 10, "schedule": "30 8 * * Mon-Fri", "durationSec": 30600, "description": "Have at least 10 VMs every Monday through Friday from 8:30 AM to 5 PM UTC" } } }}To use this example for a regional MIG,make a similar request by using theregionAutoscalers.patch methodand specify a region instead of a zone.
Onetime schedule
This example API call creates a schedule that runs once.This schedule specifies that you want a zonal MIG to containat least 30 VM instances all day on January 30, 2030 for theAmerica/New_Yorktime zone. This API call assumes that you have an existing projectnamedexample-project with a zonal MIG that is located inus-east1-band has an autoscaler namedexample-autoscaler with anexisting autoscaling policy.
PATCH https://compute.googleapis.com/compute/v1/projects/example-project/zones/us-east1-b/autoscalers?autoscaler=example-autoscaler{ "autoscalingPolicy": { "scalingSchedules": { "example-onetime-schedule": { "minRequiredReplicas": 30, "schedule": "0 0 30 1 * 2030", "timeZone": "America/New_York", "durationSec": 86400, "description": "Schedule a minimum of 30 VMs all day for January 30, 2030" } } }}To use this example for a regional MIG,make a similar request by using theregionAutoscalers.patch methodand specify a region instead of a zone.
Multiple schedules
This example API call uses theautoscalers.patch methodfor two schedules,workday-capacityandjanuary-30-2030-schedule, in a single call. This API callassumes that you have an existing project namedexample-project with azonal MIG that is located inus-east1-b and has an autoscaler namedexample-autoscaler with an existing autoscaling policy.
PATCH https://compute.googleapis.com/compute/v1/projects/example-project/zones/us-east1-b/autoscalers?autoscaler=example-autoscaler{ "autoscalingPolicy": { "scalingSchedules": { "workday-capacity": { "minRequiredReplicas": 10, "schedule": "30 8 * * Mon-Fri", "durationSec": 30600, "description": "Have at least 10 VMs every Monday through Friday from 8:30 AM to 5 PM UTC" }, "january-30-2030-schedule": { "minRequiredReplicas": 30, "schedule": "0 0 30 1 * 2030", "timeZone": "America/New_York", "durationSec": 86400, "description": "Schedule a minimum of 30 VMs all day for January 30, 2030" } } }}To use this example for a regional MIG,make a similar request by using theregionAutoscalers.patch methodand specify a region instead of a zone.
After a schedule is created, you might need to wait a few minutes to see itsstatus information.
Listing your scaling schedules
You can view a list of the schedules for a MIG. The list shows each schedule'ssettings andstatus information.
Permissions required for this task
To perform this task, you must have the followingpermissions:
- To list scaling schedules from the Google Cloud console or REST:
compute.autoscalers.geton the project
- To list scaling schedules from the Google Cloud CLI:
compute.instanceGroupManagers.geton the MIG
Console
In the Google Cloud console, go to theInstance groups page.
Click the name of a MIG in the list.
In theOverview tab, theAutoscaling section shows the signalsconfigured in the MIG.
Next to the signal information, hold the pointer over the icon, and then clickManage.
TheScaling schedules pane displays the list of your existing scalingschedules.
gcloud
To get details for a MIG,including the configurations and statuses of its scaling schedules, use thegcloud compute instance-groups managed describe command.
gcloud compute instance-groups managed describeMIG_NAME \ [--zone=ZONE | --region=REGION]
Replace the following:
MIG_NAME: the name of a MIGwith an existing autoscaling policy.ZONEorREGION: Optional:the zone or region where your MIG is located.
Any scaling schedules for your MIG are listedin the output, as shown in the following example.
...autoscalingPolicy: ... maxNumReplicas: 30 minNumReplicas: 0 ... scalingSchedules: example-onetime-schedule: description: Schedule a minimum of 30 VMs all day for January 30, 2030 disabled: false durationSec: 86400 minRequiredReplicas: 30 schedule: 0 0 30 1 * 2030 timeZone: America/New_York workday-capacity: description: Have at least 10 VMs every Monday through Friday from 8:30 AM to 5 PM UTC disabled: false durationSec: 30600 minRequiredReplicas: 10 schedule: 30 8 * * Mon-Fri timeZone: UTC...scheduledScalingStatus: example-onetime-schedule: state: READY nextStartTime: '2030-01-30T00:00:00.000-05:00' lastStartTime: '' workday-capacity: state: READY nextStartTime: '2020-11-04T08:30:00.000-00:00' lastStartTime: '2020-11-03T08:30:00.000-00:00'...
REST
To get details for an autoscaler,including the configurations and statuses of its scaling schedules,use theautoscalers.get methodfor a zonal MIG or theregionAutoscalers.get methodfor a regional MIG.
For example, make the following call to list the schedules for a zonal MIGthat has an existing autoscaling policy:
GET https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/autoscalers?autoscaler=AUTOSCALER_NAME
Replace the following:
PROJECT: yourproject id.ZONE: the zone where your MIG is located.AUTOSCALER_NAME: the name of anexisting autoscaler. This is often the same as the name of the MIG.
Any scaling schedules for your MIG are listedin the output, as shown in the following example.
{ ... "autoscalingPolicy": { ... "minNumReplicas": 0, "maxNumReplicas": 30, ... "scalingSchedules": { "example-onetime-schedule": { "minRequiredReplicas": 30, "schedule": "0 0 30 1 * 2030", "timeZone": "America/New_York", "durationSec": 86400, "description": "Schedule a minimum of 30 VMs all day for January 30, 2030", "disabled": false }, "workday-capacity": { "minRequiredReplicas": 10, "schedule": "30 8 * * Mon-Fri", "timeZone": "", "durationSec": 30600, "description": "Have at least 10 VMs every Monday through Friday from 8:30 AM to 5 PM UTC", "disabled": false }, ... } }, "scheduledScalingStatus": { "example-onetime-schedule": { "state": "READY", "nextStartTime": "2030-01-30T00:00:00.000-05:00", "lastStartTime": '' }, "workday-capacity": { "state": "READY", "nextStartTime": "2020-11-04T08:30:00.000", "lastStartTime": "2020-11-03T08:30:00.000" }, ... },...}Editing a scaling schedule
You can edit anexisting scaling scheduleto change any of itssettingsexcept for the name of the schedule. You can alsodisable or re-enable a scaling schedule.
Permissions required for this task
To perform this task, you must have the followingpermissions:
compute.autoscalers.updateon the project
Console
In the Google Cloud console, go to theInstance groups page.
Click the name of a MIG in the list.
ClickEdit.
ClickGroup size & autoscaling to expand the section.
In theAutoscaling schedules section, clickManage.
TheScaling Schedules pane displays the list of your existingscaling schedules.
Select the checkbox for the scaling schedule that you want to edit.
At the top of theScaling Schedules pane, clickEdit.
In theEdit scaling schedule pane, modify the fields that youwant to change. For more information about each field, seeCreating a scaling schedule.
When you are finished, clickSave.
You might need to wait a few minutes before your changes are effective.You can monitor the status of your schedules by clickingRefreshat the top of theScaling Schedules pane.
Close theScaling schedules pane by clickingDone.
The changes to the schedules are saved and applied to your MIG.
ClickSave to exit the edit page.
gcloud
To update an existing scaling schedule, use thegcloud compute instance-groups managed update-autoscaling command.Use the--update-schedule flag to indicate the name of the schedule toupdate. Include the other flags as needed for your changes.
gcloud compute instance-groups managed update-autoscalingMIG_NAME \ --update-schedule=SCHEDULE_NAME \ [--schedule-cron="CRON_EXPRESSION"] \ [--schedule-duration-sec=DURATION] \ [--schedule-time-zone="TIME_ZONE"] \ [--schedule-min-required-replicas=MIN_REQ_REPLICAS] \ [--schedule-description="DESCRIPTION"] \ [--zone=ZONE | --region=REGION]
Replace the following:
MIG_NAME: the name of a MIGwith an existing scaling schedule.SCHEDULE_NAME: the name of the existingscaling schedule.CRON_EXPRESSION: Optional: the new start time andrecurrence of this schedule formatted as acron expression.DURATION: Optional: the newduration, in seconds, that this schedule is active.TIME_ZONE: Optional: the newIANA time zone for the schedule's start time—forexample,Europe/Paris. The default value isUTC.MIN_REQ_REPLICAS: Optional: the new number ofminimum required instances thatthis schedule provides when it is active.DESCRIPTION: Optional: a new description of thescaling schedule.ZONEorREGION: Optional:the zone or region where your MIG is located.
REST
Note: By using the API, you can updatemultiple scalingschedules in a single call.To update the existing scaling schedules for a MIG, use theautoscalers.patch methodfor a zonal MIG or theregionAutoscalers.patch methodfor a regional MIG.
For example, make the following call to edit a schedule for a zonal MIGthat has an existing autoscaling policy:
PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/autoscalers?autoscaler=AUTOSCALER_NAME{ "autoscalingPolicy": { "scalingSchedules": { "SCHEDULE_NAME": { "minRequiredReplicas":MIN_REQ_REPLICAS, "schedule": "CRON_EXPRESSION", "timeZone": "TIME_ZONE", "durationSec":DURATION, "description": "DESCRIPTION" }, ... } }}Replace the following:
PROJECT: yourproject id.ZONE: the zone where your MIG is located.AUTOSCALER_NAME: the name of anexisting autoscaler. This is often the same as the name of the MIG.SCHEDULE_NAME: the name of the existingscaling schedule.MIN_REQ_REPLICAS: Optional: the new number ofminimum required instances thatthis schedule provides when it is active.CRON_EXPRESSION: Optional: the new start time andrecurrence of this schedule formatted as acron expression.TIME_ZONE: Optional: the newIANA time zone for the schedule's start time—forexample,Europe/Paris. The default value isUTC.DURATION: Optional: the newduration, in seconds, that this schedule is active.DESCRIPTION: Optional: a new description of thescaling schedule.
Disabling and re-enabling a scaling schedule
Scaling schedules are enabled by default. Disable a schedule if you want toprevent a schedule from being active but want to save its configuration.Re-enable a disabled schedule when you want to use it again.
If you don't need to store the schedule or have reached the 128 schedulelimit for this MIG,delete the schedule.If you want to disable autoscaling for a MIG,turn off autoscaling.
Permissions required for this task
To perform this task, you must have the followingpermissions:
compute.autoscalers.updateon the project
Console
In the Google Cloud console, go to theInstance groups page.
Click the name of a MIG in the list.
ClickEdit.
ClickGroup size & autoscaling to expand the section.
In theAutoscaling schedules section, clickManage.
TheScaling Schedules pane displays the list of your existingscaling schedules.
Select the checkboxes for the scaling schedules that you want to disableor enable.
To disable the selected schedules:
- At the top of theScaling Schedules pane, clickDisable.
- In theDisable schedules dialog, clickDisable.
To enable the selected schedules:
- At the top of theScaling Schedules pane, clickEnable.
- In theEnable schedules dialog, clickEnable.
You might need to wait a few minutes before your changes are effective.You can monitor the status of your schedules by clickingRefreshat the top of theScaling Schedules pane.
Close theScaling schedules pane by clickingDone.
The changes to the schedules are saved and applied to your MIG.
ClickSave to exit the edit page.
gcloud
To disable or re-enable a scaling schedule, use thegcloud compute instance-groups managed update-autoscaling command.
Disabling a scaling schedule
To disable a scaling schedule, use the--disable-schedule flag.
gcloud compute instance-groups managed update-autoscalingMIG_NAME \ --disable-schedule=SCHEDULE_NAME \ [--zone=ZONE | --region=REGION]
Replace the following:
MIG_NAME: the name of a MIGwith an existing scaling schedule.SCHEDULE_NAME: the name of thescaling schedule that you want to disable.ZONEorREGION: Optional:the zone or region where your MIG is located.
Re-enabling a scaling schedule
To re-enable a scaling schedule, use the--enable-schedule flag.
gcloud compute instance-groups managed update-autoscalingMIG_NAME \ --enable-schedule=SCHEDULE_NAME \ [--zone=ZONE | --region=REGION]
Replace the following:
MIG_NAME: the name of a MIGwith an existing scaling schedule.SCHEDULE_NAME: the name of thescaling schedule that you want to re-enable.ZONEorREGION: Optional:the zone or region where your MIG is located.
REST
Note: By using the API, you can disable and re-enablemultiple scalingschedules in a single call.To disable or re-enable scaling schedules for a MIG, use theautoscalers.patch methodfor a zonal MIG or theregionAutoscalers.patch methodfor a regional MIG.
Disabling scaling schedules
For each scaling schedule that you want to disable,set thedisabled field totrue.For example, make the following call to disable a schedule for a zonal MIGthat has an existing autoscaling policy:
PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/autoscalers?autoscaler=AUTOSCALER_NAME{ "autoscalingPolicy": { "scalingSchedules": { "SCHEDULE_NAME": { "disabled": true }, ... } }}Replace the following:
PROJECT: yourproject id.ZONE: the zone where your MIG is located.AUTOSCALER_NAME: the name of anexisting autoscaler. This is often the same as the name of the MIG.SCHEDULE_NAME: the name of thescaling schedule that you want to disable.
Re-enabling scaling schedules
For each scaling schedule that you want to re-enable,set thedisabled field tofalse.For example, make the following call to re-enable a schedule for a zonal MIGthat has an existing autoscaling policy:
PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/autoscalers?autoscaler=AUTOSCALER_NAME{ "autoscalingPolicy": { "scalingSchedules": { "SCHEDULE_NAME": { "disabled": false }, ... } }}Replace the following:
PROJECT: yourproject id.ZONE: the zone where your MIG is located.AUTOSCALER_NAME: the name of anexisting autoscaler. This is often the same as the name of the MIG.SCHEDULE_NAME: the name of thescaling schedule that you want to re-enable.
Deleting a scaling schedule
Remove scaling schedules from a MIG by deleting them.Delete schedules that you no longer need, such as schedules with anOBSOLETEstatus.
An autoscaling policy must always have at least one scaling signal. If no otherautoscaling signal exists, then you cannot delete all scalingschedules without deleting the entire autoscaling policy. If you want to deleteall scaling schedules but keep the autoscaling policy, you must add at least onescaling signal prior to deleting all the schedules.
If you want to prevent a schedule from becoming active and save it for futureuse,disable the schedule.If you want to delete the autoscaling configuration for a MIG,delete the autoscaler.
Permissions required for this task
To perform this task, you must have the followingpermissions:
compute.autoscalers.updateon the project
Console
In the Google Cloud console, go to theInstance groups page.
Click the name of a MIG in the list.
ClickEdit.
ClickGroup size & autoscaling to expand the section.
In theAutoscaling schedules section, clickManage.
TheScaling Schedules pane displays the list of your existingscaling schedules.
- Select the checkboxes for the scaling schedules that you want to delete.
- At the top of theScaling Schedules pane, clickDelete.
In theDelete schedules dialog, type
delete, and thenclickDelete.You might need to wait a few minutes before your changes are effective.You can monitor the status of your schedules by clickingRefreshat the top of theScaling Schedules pane.
Close theScaling schedules pane by clickingDone.
The changes to the schedules are saved and applied to your MIG.
ClickSave to exit the edit page.
gcloud
To delete a scaling schedule, use thegcloud compute instance-groups managed update-autoscaling commandwith the--remove-schedule flag.
gcloud compute instance-groups managed update-autoscalingMIG_NAME \ --remove-schedule=SCHEDULE_NAME \ [--zone=ZONE | --region=REGION]
Replace the following:
MIG_NAME: the name of a MIGwith an existing scaling schedule.SCHEDULE_NAME: the name of thescaling schedule that you want to delete.ZONEorREGION: Optional:the zone or region where your MIG is located.
REST
Note: By using the API, you can deletemultiple scalingschedules in a single call.To delete scaling schedules for a MIG, use theautoscalers.patch methodfor a zonal MIG or theregionAutoscalers.patch methodfor a regional MIG. For each scaling schedule that you want to delete,set the schedule configuration tonull
For example, make the following call to delete a schedule for a zonal MIGthat has an existing autoscaling policy:
PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/autoscalers?autoscaler=AUTOSCALER_NAME{ "autoscalingPolicy": { "scalingSchedules": { "SCHEDULE_NAME": null ... } }}Replace the following:
PROJECT: yourproject id.ZONE: the zone where your MIG is located.AUTOSCALER_NAME: the name of anexisting autoscaler. This is often the same as the name of the MIG.SCHEDULE_NAME: the name of thescaling schedule that you want to delete.
Concepts
This section describes concepts related to creating and using scaling schedulesincluding schedule settings and details about how they work.
Scaling schedule settings
When you create and modify the scaling schedules for a MIG, each scalingschedule contains the following settings:
Minimum required instances: Thenumber of VMs you require in the MIG when thisscaling schedule is active.
When this schedule is active, the MIG has at least thisnumber of VMs, but might have moredepending on other autoscaling settings. Additionally, the MIGsize is always restricted by the minimum and maximum number of instancesconfigured in the MIG's autoscaling settings.
Time zone: The location-based IANA time zone for interpreting theschedule's start time.
Alist of available values is defined by theIANA time zone database—forexample,
Europe/Paris. If no time zone is provided,UTCis used bydefault. Some IANA time zones observe daylight saving time. To learn howdaylight saving time affects scaling schedules, seeDaylight saving time.Duration: The amount of time that you want the scalingschedule to be active.
The scaling schedule is active from its start time for the configuredduration. The minimum duration is 5 minutes. During this time, autoscalerscales the MIG to have at least as many VMs as defined bythe schedule's required instances. After the specified duration, if thecurrent capacity is no longer needed, the autoscaler starts removingVM instances after a default10-minute stabilization periodand following any configuredscale-in controls.
Scaling schedules are bidirectional. VMs are removed at the stop time thatyou specify and the group size is reduced to the minimum group size that youset, unless you have specified other autoscaling signals.
When using the Google Cloud CLI or REST,you must configure the start time and recurrenceof a scaling schedule by using acron expression.However, whenusing Google Cloud console, you can configure the start time and recurrence of aschedule either by using a cron expression or the following settings:
Start time: The time of day when youwant the scaling schedule to become active.
At the start time, the scaling schedule begins creating VMs wheneverthe MIG size is lower than the schedule's required instances.Set the start time to allow enough time for new VMs to boot andinitialize. For example, if your workload takes 10 minutes fromVM creation to begin serving, then set the start time to be 10 minutesearlier than the time you need the VMs to be ready.
Recurrence: If and how often the scaling schedulerepeats, as defined by the following options:
- Once: a onetime schedule that starts only on the selected date.
- Every day: a repeating schedule that starts every day.
- Every week: a repeating schedule that starts every week on theselected days of the week—for example, every Monday through Friday.
- Every month: a repeating schedule that starts every month on theselected days of the month—for example, on the first day of every month.The last days of the month (days 29 through 31) are only effective duringthe months when those days occur.
Cron expressions
The start time and recurrence of a scaling schedule can be configured by using acron expression.Cron is a time-based job scheduler originally used in Unix-likecomputer operating systems.
Syntax
A cron expression is a string comprisingof five or six fields separated by whitespace. The following tabledefines the fields of a cron expression and the possible values for each field.
| Minute | Hour | Day of the month | Month | Day of the week | Year (optional) |
|---|---|---|---|---|---|
| 0-59 | 0-23 | 1-31 | 1-12 (Jan-Dec) where 1=Jan,2=Feb, ...12=Dec | 0-6 (Sun-Sat) or 1-7 (Mon-Sun) where 0=Sun,1=Mon, ...6=Sat,7=Sun | 2000-2036 or every year ( *) if not provided |
In addition to using these values, every field in a cron expression canalso use special characters:
| Special character | Meaning | Example |
|---|---|---|
* | any | If the day of month field, day of the week field, and year field (if included) are each set to*, then the schedule starts everyday. |
- | range | If the day of week field is set to1-5 orMon-Fri, then the schedule starts every week Monday to Friday. |
, | list | If the month field is set to5,7,9 orMay,Jul,Sep, then the schedule starts every May, July, and September. |
/ | step | If the month field is set to*/3, then the schedule starts during the first month and every 3 months after that: January, April, July, and October. |
When you write a cron expression, consider the following:
- Whitespace is used to separate the fields of a cron expression. Remember tonot add extra whitespace in a field that is using special characters.
- When you specify both a day of the week and a day of the month (when neitherfield is set to
*), the schedule uses the union of these values, not theintersection. For example, the schedule0 8 1 * Monstarts at 8:00 AMon every Monday and on the first day of every month. That schedule doesnotstart at 8:00 AM only on Mondays that are also the first day of the month. - You can use zero or more special characters ineach field of a cron expression.For example, if you want a schedule to start every month except May,you can set the month field to
1-4,6-12(a list of two rangeswithout whitespace). - When using ranges (
-), you cannot use0-7orSun-Sunfor the day of the week field—to specify everyday of the week, use*,0-6,1-7,Sun-Sat,orMon-Suninstead. - When using steps (
/), remember that cron expressions are stateless,so steps can sometimes be uneven. For example, if you want a schedule to runevery 6 hours, you can set the hours field to*/6, which behaves the same aslisting every valid multiple of 6 (0,6,12,18). The steps are even because 24hours is divided into 6-hour parts. However, if you set the hours fieldto*/7, the schedule won't always start in 7-hour intervals. Instead,*/7behaves the same as listing every valid multiple of 7 (0,7,14,21), meaningthat the schedule can start during the hours of 12 AM, 7 AM, 2 PM, and 9 PM.
Repeating schedules versus onetime schedules
Depending on how you write your cron expression, your schedule might runonce or periodically repeat. To create a schedule that only runs once, youmust specify the year field. For example, the cron expression0 0 30 1 * 2030configures a schedule to only start once, at midnight on January 30, 2030.To create a schedule that repeats, use special characters to describe whenthat schedule is to repeat. For example, the cron expression30 8 * * Mon-Fri configures a scheduleto start at 8:30 AM on every Monday, Tuesday, Wednesday, Thursday, and Friday.
Schedule status information
List your scaling schedules to view theirstatus. A scaling schedule has the following status information:
- Status (
state): The current status of the scaling schedule, representedby one of the following states:- Ready (
READY): This schedule is ready but not active yet.Autoscaler is awaiting the next occurrence of this schedule. - Active (
ACTIVE): This schedule is active. Autoscaleris trying to provide this MIG with at least the required instances that thisschedule specifies. - Obsolete (
OBSOLETE): This schedule has expired; it won't be activeagain. Autoscaler is ignoring this schedule because there are no futureoccurrences. - Disabled (
DISABLED): This schedule cannot be active because it was manuallydisabled. Autoscaler is ignoring this schedule until it is re-enabled.
- Ready (
- Last occurrence (
lastStartTime): The timestamp of the last time thisscaling schedule became active. This is the actual date and time of thelast activation. For example, if you have a disabled scaling schedulewith a daily recurrence, 10 AM start time, and 2-hour duration, andyou re-enable the schedule at 11 AM today, then thelastStartTimeis11 AM today. - Next occurrence (
nextStartTime): The timestamp of the next time thisschedule is set to become active.
Overlapping schedules
Depending on start time, recurrence, duration, and time zone, two or morescaling schedules might overlap. When more than one schedule is active,the autoscaler uses the greatest number of required VM instancesfrom all active scaling schedules. This helps you ensure that there is alwaysenough capacity to meet the needs of any active schedule. For example, ifyou have a schedule that recurs every day 8 AM to 10 AM requiring at least10 VMs, but also have a one-off all-day schedule requiring at least 20 VMs,then autoscaler scales the MIG to at least 20 VMs on that day.This is useful when you have regular, recurring capacity requirements butsometimes need more to handle onetime events. This behavior lets youschedule capacity without worrying about it being overridden by otherschedules with smaller VM requirements.
Additionally, an autoscaler always provides the greatest number of VM instancesrequired by any active autoscaling signal. For more information, seeUsing an autoscaling policy with multiple signals.
Daylight saving time
The details ofdaylight saving time (DST) vary according to your scaling schedule'slocation-based IANA time zone.If your schedule's time zone observes DST, the schedule's start timeautomatically adjusts to stay synchronized with the time for the selectedlocation. For example, if you create a scaling schedule that starts everyday at 7 AM for the time zoneAmerica/New_York, then this schedule startswhenever it is 7 AM in New York, using Eastern DaylightTime or Eastern Standard Time accordingly.
Scaling schedules always run for the entire duration that you configure, butthey might have slightly different start and end times on the days when DSTobservation switches. This happens because DST switches havetransition periods—a timeframe that is skipped on the first day of DSTand that occurs twice on the last day of DST. For example, if DST for yourtime zone begins at 2 AM and has a 1-hour transition, then the clock changesfrom 1:59:59 AM to 3 AM, so the timeframe 2 AM to 2:59:59 AM is skipped. IfDST for that time zone ends at 2 AM, then the clock changes from 2:59:59 AM to2 AM, so the timeframe 2 AM to 2:59:59 AM is repeated. The following statementsassume that the time zone for your schedule uses a 1-hour DST transition.
On the first day of DST (when 1 hour is skipped), scaling schedules havethe following changes:
- Schedules that are active during the skipped hour stillrun for their entire duration, but to compensatefor the skipped hour, these schedules end 1 hour later than their end timeon days without DST transitions. Normally, the end timeof a schedule is the sum of the schedule's start time and duration.But if DST skips 1 hour while a schedule is active,and the duration and start time remain constant, then the end time forthat schedule is 1 hour more than the sum of the schedule'sstart time and duration.
- Schedules that are configured to start during the skipped houralso start 1 hour later than their start timeon days without DST transitions.
On the last day of DST (when 1 hour is repeated), scaling schedules havethe following changes:
- Schedules that are active during the repeat hour stillrun for their entire duration, but to compensatefor the repeated hour, these schedules end 1 hour earlierthan their end time on days without DST transitions.Normally, the end time of a schedule isthe sum of the schedule's start time and duration.But if DST repeats 1 hour while a schedule is active,and the duration and start time remain constant, then the end time forthat schedule is 1 hour less than the sum of the schedule'sstart time and duration.
- Schedules that are configured to start during the transition periodstart at their configured time, but they don't restart during the second,repeated occurrence of the start time.
Most of the time zones that observe DST use a 1-hour transitionperiod. But, if the time zone for your schedule uses a differenttransition period—such astheAustralia/Lord_Howe time zone, which uses 30-minutetransitions—you can expect the same behavior. Just replace1 hourwith the relevant DST transition time.
What's next
- Learn aboutusing an autoscaling policy with multiple signals.
- Learn aboutmanaging autoscalers.
- Learn aboutunderstanding autoscaler decisions.
- Learn how to autoscale MIGs based on other types of autoscaling signals:
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-15 UTC.