A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cloud.google.com/compute/docs/instance-groups/create-mig-with-basic-autoscaling below:

Create a MIG with autoscaling enabled | Compute Engine Documentation

Create a MIG with autoscaling enabled

Stay organized with collections Save and categorize content based on your preferences.

This document describes how to create an autoscaled managed instance group (MIG) that automatically adds and removes VMs based on average CPU utilization across the group. For example, if the group's CPU utilization is low, the group automatically removes VMs to save on costs.

You can automatically scale a MIG based on various kinds of autoscaling signals. For more information, see the autoscaler overview.

You can also read about other basic scenarios for creating a MIG.

Before you begin Limitations

To see the full list of MIG limitations, which varies based on the configuration that you use, see MIG limitations.

Create a MIG and enable autoscaling

Use the Google Cloud console, the gcloud CLI, Terraform, or REST.

Permissions required for this task

To perform this task, you must have the following permissions:

Console
  1. In the console, go to the Instance groups page.

    Go to Instance groups

    The remaining steps appear in the Google Cloud console.

  2. If you have an instance group, select it and click Edit. If you don't have an instance group, click Create instance group .
  3. For a new instance group, assign a name, then choose an instance template for the instance group or create a new one.
  4. If no autoscaling configuration exists, under Autoscaling, click Configure autoscaling.
  5. Under Autoscaling mode , select On: add and remove instances to the group to enable autoscaling.
  6. Specify the minimum and maximum numbers of instances that you want the autoscaler to create in this group.
  7. In the Autoscaling metrics section, if an existing CPU utilization metric does not yet exist, add one:
    1. Click Add metric .
    2. Under Metric type , select CPU utilization.
    3. Enter the Target CPU utilization that you want. This value is treated as a percentage. For example, for 75% CPU utilization, enter 75.
    4. Under Predictive autoscaling, select Off . To learn more about predictive autoscaling, and whether it is suitable for your workload, see Scaling based on predictions.
    5. Click Done.
  8. You can use the Initialization period to set the initialization period, which tells the autoscaler how long it takes for your application to initialize. Specifying an accurate initialization period improves autoscaler decisions. For example, when scaling out, the autoscaler ignores data from VMs that are still initializing because those VMs might not yet represent normal usage of your application. The default initialization period is 60 seconds.
  9. To create the MIG, click Create .
gcloud

Before you can enable autoscaling, you must create a MIG. Follow the instructions to create a MIG with VMs confined to a single zone or create a MIG with VMs spread across multiple zones in a region.

Then use the set-autoscaling sub-command to enable autoscaling for the group. For example, the following command creates an autoscaler that has a target CPU utilization of 60%. Along with the --target-cpu-utilization parameter, the --max-num-replicas parameter is also required when creating an autoscaler.

Optionally, you can set the --min-num-replicas indicating the minimum number of VMs that you want in the group. If you don't set the minimum, by default, MIG sets this value to 2.

You can use the --cool-down-period flag to set the initialization period, which tells the autoscaler how long it takes for your application to initialize. Specifying an accurate initialization period improves autoscaler decisions. For example, when scaling out, the autoscaler ignores data from VMs that are still initializing because those VMs might not yet represent normal usage of your application. The default initialization period is 60 seconds.

Note: If autoscaling is already enabled for a managed instance group, the set-autoscaling command overwrites the existing autoscaler to the new specifications.
gcloud compute instance-groups managed set-autoscaling example-managed-instance-group \
  --max-num-replicas 20 \
  --target-cpu-utilization 0.60 \
  --cool-down-period 90

If you want, you can enable predictive autoscaling to scale out ahead of predicted load. To learn whether predictive autoscaling is suitable for your workload, see Scaling based on predictions.

You can verify that autoscaling is successfully enabled by using the instance-groups managed describe command, which describes the corresponding MIG and provides information about any autoscaling features for that group:

gcloud compute instance-groups managed describe example-managed-instance-group
Terraform

Before you can enable autoscaling, you must create a MIG. Follow the instructions to create a MIG with VMs confined to a single zone or create a MIG with VMs spread across multiple zones in a region.

To configure autoscaling in a MIG, you can use the google_compute_autoscaler resource.

The following sample configures autoscaling based on CPU utilization in a zonal MIG.

To learn how to apply or remove a Terraform configuration, see Basic Terraform commands.

REST

Before you can enable autoscaling, you must create a MIG with VMs confined to a single zone or create a MIG with VMs spread across multiple zones in a region.

Note: Although autoscaling is a feature of managed instance groups, it is a separate API resource. Keep that in mind when you construct API requests for autoscaling.

If you have a zonal MIG, make a POST request to the autoscalers.insert method. If you have a regional MIG, use the regionAutoscalers.insert method.

For example:

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

Your request body must contain the name, target, and autoscalingPolicy fields. The autoscalingPolicy field must define your target cpuUtilization value and maxNumReplicas value.

Optionally, you can set the minNumReplicas indicating the minimum number of VMs that you want in the group. If you don't set the minimum, by default, MIG sets this value to 2.

You can use the coolDownPeriodSec field to set the initialization period, which tells the autoscaler how long it takes for your application to initialize. Specifying an accurate initialization period improves autoscaler decisions. For example, when scaling out, the autoscaler ignores data from VMs that are still initializing because those VMs might not yet represent normal usage of your application. The default initialization period is 60 seconds.

{
  "name": "example-autoscaler",
  "target": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/instanceGroupManagers/example-managed-instance-group",
  "autoscalingPolicy": {
    "maxNumReplicas": 10,
    "cpuUtilization": {
      "utilizationTarget": 0.6
    },
    "coolDownPeriodSec": 90
  }
}

If you want, you can enable predictive autoscaling to scale out ahead of predicted load. To learn whether predictive autoscaling is suitable for your workload, see Scaling based on predictions.

For more information about enabling autoscaling based on CPU utilization, see Scaling based on CPU utilization.

What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This guide explains how to create an autoscaled managed instance group (MIG) that automatically adjusts the number of virtual machines (VMs) based on average CPU utilization to optimize costs and performance."],["To begin, you must have an instance template and have set up authentication, either through the Google Cloud console, gcloud CLI, Terraform, or REST API."],["Autoscaling can be configured with options for minimum and maximum instances, target CPU utilization, and an initialization period to improve decision-making during scaling."],["Autoscaling for MIGs can be enabled using the Google Cloud console, gcloud CLI, Terraform, or REST API, and allows for customization with parameters such as maximum and minimum number of VMs and cool-down period."],["The Autoscaler also provides predictive autoscaling to scale out ahead of predicted load, and you can find more information on when to use this feature in the provided documentation."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4