Using Multiple Policies

Create an autoscaler with multiple policies and the autoscaler will scale based on the policy that provides the largest number of virtual machines in the group. This ensures that there is always enough virtual machines to handle your application workloads and allows you to scale applications with multiple possible bottlenecks.

Before you begin

How autoscaler handles multiple policies

The autoscaler handles multiple policies by calculating the recommended number of virtual machines for each policy and then picking the policy that leaves the largest number of virtual machines in the group. An autoscaler can handle a maximum of five policies at a time.

For example, if you defined an autoscaler with all of the following policy definitions:

  • cpuUtilization with target of 0.8.
  • loadBalancingUtilization with target of 0.6.
  • customMetricUtilization for metric1 with target of 1000.
  • customMetricUtilization for metric2 with target of 2000.

And the autoscaler measures the following average values for the managed instance group that contains 10 virtual machines:

  • 0.5 for CPU utilization.
  • 0.4 load balancing utilization.
  • 1100 for metric1.
  • 2700 for metric2.

Using the average values, the autoscaler calculates recommended changes to the number of virtual machines, based on each policy:

  • 7 virtual machines based on CPU utilization.
  • 7 virtual machines based on load balancing utilization.
  • 11 virtual machines based on metric1.
  • 14 virtual machines based on metric 2.

Given that there is more than one policy for this autoscaler, the autoscaler chooses the largest recommend value, in this case, 14 machines, and resizes the managed instance group to 14 virtual machines.

Create an autoscaler with multiple policies

Creating an autoscaler with multiple policies is slightly different depending on whether you are using the gcloud command-line tool or the API.


  1. Go to the Instance groups page.
  2. Select the desired instance group from the list and click Edit.
  3. On the instance group details page under Autoscaler, select On from the drop-down menu to turn on autoscaling.
  4. In the Autoscale based on section, select Multiple metrics from drop-down menu.

    Screenshot selecting multiple policies

  5. Fill in fields for CPU utilization and load balancing utilization, if desired.

  6. To add custom metric policies, click on the + icon under the Target monitoring metrics section and fill in the fields for a custom metric policy.

    Screenshot showing custom metrics

    You can add multiple custom metric policies by clicking the + icon.


To create an autoscaler with multiple policies, pass in multiple policy specifications using the respective command-line flags. The following command creates an autoscaler that uses CPU utilization, load balancing utilization, and two custom metrics:

gcloud compute instance-groups managed set-autoscaling example-managed-instance-group \
    --target-cpu-utilization 0.8 \
    --custom-metric-utilization,utilization-target=1000.0,utilization-target-type=GAUGE \
    --custom-metric-utilization,utilization-target=2000.0,utilization-target-type=DELTA_PER_SECOND \
    --target example-managed-instance-group \
    --max-num-replicas 50

With the exception of the custom metric flags, you can only pass in one flag maximum for each metric type.

For custom metrics, you can provide multiple custom metrics by repeating the following flags:

--custom-metric-utilization metric=METRIC,utilization-target=TARGET,utilization-target-type=TYPE


In the API, make a POST request with the request body containing all of the desired policies:


{ "autoscalingPolicy" : { "cpuUtilization":{ "utilizationTarget": 0.8 }, "customMetricUtilizations":[ { "metric": "", "utilizationTarget": 1000, "utilizationTargetType":"GAUGE" }, { "metric": "", "utilizationTarget": 2000, "utilizationTargetType": "DELTA_PER_SECOND" } ], "loadBalancingUtilization":{ "utilizationTarget": 0.6 }, "maxNumReplicas": 50, "minNumReplicas": 1 } "target": "", "name": "example-autoscaler" }

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Compute Engine Documentation