Applying sizing recommendations for VM instances

Compute Engine provides machine type recommendations to help you optimize the resource utilization of your virtual machine (VM) instances. These recommendations are generated automatically based on system metrics gathered by the Cloud Monitoring service over the previous 8 days. Use these recommendations to resize your instance's machine type to more efficiently use the instance's resources. This feature is also known as rightsizing recommendations.

To learn more about the different sizing options available to VM instances, read the machine types documentation.

Before you begin


Sizing recommendations are available free of charge.

Limitations and use cases

Sizing recommendations are currently not available for VM instances created using App Engine flexible environment, Dataflow, or Google Kubernetes Engine, or for VM instances with ephemeral disks, GPUs, or TPUs.

The sizing recommendation algorithm is suited to workloads that follow weekly patterns, workloads that grow or shrink over weeks of time, workloads that persistently underutilize their resources, or workloads that are persistently throttled by insufficient resources. In such cases, 8 days of historical data is enough to predict how a change in the size of the machine can improve resource utilization.

The sizing recommendation algorithm is less suited to the following workloads:

  • Workloads that spike infrequently (for example, monthly spikes) because 8 days of data is not enough to capture or predict the CPU fluctuations.
  • Workloads that have very brief CPU spikes because recommendations are based on average CPU utilization over 60-second intervals. Recommendations might not be generated quickly enough to capture shorter spikes. See How sizing recommendations work for more information.

For workloads where cost is more important to you than performance, such as batch workloads, you can ignore recommendations to increase size.

In rare cases, you might see an error message when applying a recommendation. For example, a recommended machine type might be too small for the number of attached disks, it might not meet the resource requirements of your images or licenses, or it might not be available in a particular zone.

How sizing recommendations work

Compute Engine monitors the CPU and memory utilization of running VMs and makes recommendations using the last 8 days of data. Compute Engine makes recommendations like the following:

  • If your instance has had low CPU utilization most of the time, Compute Engine recommends a machine type with fewer virtual CPUs.

  • If your instance has had high CPU utilization most of the time, Compute Engine recommends a machine type with more virtual CPUs.

  • If your instance hasn't used a large fraction of its memory, Compute Engine recommends a machine type with less memory.

  • If your instance has actively been using a large fraction of its memory most of the time. Compute Engine recommends a machine type with more memory.

Compute Engine might make recommendations to use either a standard or custom machine type. Note that there are some limitations in the amount of memory and vCPU available to a machine. In particular, increasing one resource might require increasing the other at the same time, to follow the specifications of a valid machine type. Also, Compute Engine only recommends machine types that are available in the zone where the instance is running.

See custom machine type specifications for details.

For cost difference estimations, the cost of an instance is based on the previous week's usage (before sustained use discount) and is extrapolated to 30 days. This is then compared to the recommended machine type monthly cost (before sustained use discount). For accurate pricing and details, read the pricing documentation.

Viewing sizing recommendations

Compute Engine makes recommendations available through the Google Cloud Console. Recommendations are also available through the Recommender using the gcloud tool or the API.


  1. In the Google Cloud Console, go to the VM instances page.

    Go to the VM instances page

  2. Select your project and click Continue.
  3. On your list of instances, click the Columns drop-down list on the upper-right corner to toggle one or more columns.
  4. Enable or disable the columns that you want, including Recommendation.
  5. Look at the Recommendation column to review recommendations for individual instances. You can also sort the column by amount of estimated savings. If there are no recommendations next to your instances, Compute Engine doesn't have any recommendations to make.

    Recommendations column


Use the gcloud recommender recommendations list command and specify the VM instance rightsizing recommender.

For example:

gcloud recommender recommendations list \
    --project my-project \
    --location us-central1-a \
    --recommender=google.compute.instance.MachineTypeRecommender \

    - operations:
      - action: test
        path: /machineType
        resource: //
          matchesPattern: .*zones/us-central1-a/machineTypes/n1-standard-4
      - action: replace
        path: /machineType
        resource: //
        value: zones/us-central1-a/machineTypes/custom-2-5120

description: Save cost by changing machine type from n1-standard-4 to custom-2-5120.
name: projects/548293842938/locations/us-central1-a/recommenders/google.compute.instance.MachineTypeRecommender/recommendations/5c3b62bd-87c3-4d13-9c31-f80c7cbe412f

The response includes the following fields:

  • name: the name of the recommendation
  • description: a human-readable explanation of the recommendation.
  • operationGroups: groups of operations that you can perform in serial order to apply the recommendation.

For more information, see the Recommender docs.


Use the Recommender API with the VM instance rightsizing recommender ID.

If you aren't already familiar with the authentication prerequisites for calling Google Cloud APIs, see the Authentication overview.

The following example bash script uses the end user authentication flow with an OAuth client credential. The script uses the Google oauth2l command-line tool to get an OAuth 2.0 access token and then makes a curl request using the token.

OAUTH_JSON=~/client_secrets.json  # credentials for service account
OAUTH_HEADER="$(oauth2l header --json $OAUTH_JSON cloud-platform)"

curl -H "$OAUTH_HEADER"$PROJECT_ID/locations/$LOCATION/recommenders/$RECOMMENDER_ID/recommendations

The response includes the following fields:

  • name The name of the recommendation
  • description A human-readable explanation of the recommendation.
  • operationGroups Groups of operations that you can perform in serial order to apply the recommendation.

For more information, see the Recommender docs.

When you create an instance, recommendations for the instance appear 24 hours after the instance was created. If you change the machine type of an instance, Compute Engine provides any further recommendations within 24 hours after the change.

After that, VM instance recommendations are refreshed at regular intervals throughout the day.

Resizing instances according to recommendations

If you determine that you want to apply the recommendations made by Compute Engine, you can resize the instance directly from the recommendations screen, or manually step through the operations that are returned when viewing sizing recommendations.


  1. In the Google Cloud Console, on the VM instances page, click the recommendation text for the instance you want to resize.

    Recommendations link

  2. A pop-up appears with more detail and an Apply button to apply the recommendations to the instance. When you click this button, Compute Engine stops the instance, changes its machine type, and restarts the instance.

  3. Optionally, you can also click the Customize link to customize the instance as you prefer.

    Recommendations details popup

  4. Click the Apply button to apply the changes.


See Changing a machine type for information.


See Changing a machine type for information.

Dismissing and restoring recommendations

When you have finishing using a recommendation, you can dismiss it from the console. Within the console, dismissing removes a recommendation from the total savings estimate and also minimizes the appearance of the recommendation so that it appears dimmed.

Acting on a recommendation through the console does not affect the list of or states of recommendations that are returned by the Recommender API. To manage the state of recommendations returned by the Recommender API, see Using the API.

To dismiss a single recommendation from the console:

  1. On the VM instances page, click the recommendation text you want to dismiss.

  2. A pop-up appears with more detail and a Dismiss recommendation button.

    Dismiss recommendations.

  3. Click Dismiss recommendation.

To dismiss all recommendations, click the Dismiss all button on the VM instances page.

Dismiss recommendations.

To restore a recommendation:

  1. In the Google Cloud Console, on the VM instances page, click the dimmed recommendation text you want to restore.

    Dismissed recommendation

  2. A pop-up appears with more detail and a Restore recommendation button.

    Dismiss recommendations

  3. Click Restore recommendation.

Using the monitoring agent for more precise recommendations

Cloud Monitoring offers a Monitoring agent that collects additional disk, CPU, network, and process metrics from your VM instances. To collect this data, install the Monitoring agent on your VM instances so it can access system resources and app services.

If the Monitoring agent is installed and running on a VM instance, the CPU and memory metrics collected by the agent are automatically used to compute sizing recommendations. The agent metrics provided by the Monitoring agent give better insights into resource utilization of the instance than the default Compute Engine metrics. This allows the recommendation engine to estimate resource requirements better and make more precise recommendations.

To install the agent, see Installing the Monitoring agent.

What's next