Reduce overprovisioned Cloud SQL instances

The Cloud SQL overprovisioned instance recommender helps you detect instances that are unnecessarily large for a given workload. It then provides you recommendations on how to resize such instances and reduce cost. This page describes how this recommender works and how to use it.

How it works

The Cloud SQL overprovisioned recommender analyzes the usage metrics of primary instances that are older than 30 days. The recommender does not analyze read replicas.

For each instance, this recommender considers the CPU and memory utilization based on the values of certain metrics within the last 30 days.

If the peak utilization of either or both the CPU and the memory within the 30-day observation period is low, the instance is estimated to be overprovisioned. Recommendations are generated every 24 hours for rightsizing such instances when the estimated monthly cost savings are greater than or equal to $10. .

This recommender uses conservative thresholds to ensure that it flags only instances that are significantly overprovisioned, which is usually a good indicator of waste. The recommender suggests a machine type that has at least 4 vCPUs and 26 GB.

Pricing

The Cloud SQL overprovisioned instance recommender is in the Standard Recommender pricing tier.

Before you begin

Before you can view the recommendations and insights, do the following:

  • To use the Google Cloud Console, read the related documentation.
  • To use the command-line examples, install or update to the latest version of the gcloud command-line tool.
  • To use the API examples in this guide, set up API access.
  • Make sure that you have the required roles. These roles provide a set of permissions that enable you to view and work with the insights and recommendations.
    Tasks Roles
    View recommendations Either recommender.cloudsqlViewer or cloudsql.viewer
    Apply recommendations One of these: recommender.cloudsqlAdmin, cloudsql.editor, or cloudsql.admin
    For more information about roles, see understanding roles and granting IAM permissions.
  • Enable the Recommender API.

    Enable the API

List overprovisioned Cloud SQL instance recommendations

You can list the overprovisioned instance recommendations by using the Cloud Console, gcloud, and the Recommender API.

Console

To list recommendations about overprovisioned instances by using the Cloud Console, follow these steps:

  1. In the Cloud Console, go to the Recommendation Hub.

    Go to the Recommendation Hub

    For more information, see Getting started with Recommendation Hub.

  2. In the Reduce Cloud SQL instance cost card, click View all.

  3. Click the Reduce instance tab.

gcloud

To list recommendations about overprovisioned instances by using gcloud, run the gcloud recommender recommendations list command with the recommender specified as OverprovisionedRecommender:

gcloud recommender recommendations list \
--project=PROJECT_ID \
--location=LOCATION \
--recommender=google.cloudsql.instance.OverprovisionedRecommender

Replace the following:

  • PROJECT_ID: Your project ID.
  • LOCATION: A region, such as us-central1.

API

To view recommendations about overprovisioned instances by using the Recommendations API, call the recommendations.list method as follows, with the recommender specified as OverprovisionedRecommender.

GET https://recommender.googleapis.com/v1beta1/projects/PROJECT-ID/locations/LOCATION/recommenders/google.cloudsql.instance.OverprovisionedRecommender/recommendations

Replace the following:

  • PROJECT_ID: Your project ID.
  • LOCATION: A region, such as us-central1.

If overprovisioned instances are detected, these are listed in a table showing a brief recommendation, the instance name, the current machine type, the recommended machine type, the location, and the last refresh date.

View insights about overprovisioned Cloud SQL instances and apply recommendations

You can view insights about overprovisioned instances and detailed recommendations by using the Cloud Console, gcloud, and the Recommender API.

Console

To view insights about an overprovisioned instance by using the Cloud Console, click a recommendation from the list of recommendations in the Reduce instance tab.

gcloud

To view insights about overprovisioned instances by using gcloud, run the gcloud recommender insights list command as follows:

gcloud recommender insights list \
--project=PROJECT_ID \
--location=LOCATION \
--insight-type=google.cloudsql.instance.INSIGHT_TYPE

Replace the following:

  • PROJECT_ID: Your project ID.
  • LOCATION: A region, such as us-central1.
  • INSIGHT_TYPE: The ID of the insight type as CpuUsageInsight or MemoryUsageInsight, which provide insights about CPU usage and memory, respectively.

API

To view insights about overprovisioned instances by using the Recommendations API, call the insights.list method as follows.

GET https://recommender.googleapis.com/v1beta1/projects/PROJECT-ID/locations/LOCATION/insightTypes/google.cloudsql.instance.INSIGHT_TYPE/insights

Replace the following:

  • PROJECT_ID: Your project ID.
  • LOCATION: A region, such as us-central1.
  • INSIGHT_TYPE: The ID of the insight type as CpuUsageInsight. or MemoryUsageInsight, which provide insights about CPU usage and memory, respectively.

A panel appears showing insights about the current memory and CPU utilization of the instance. The following categories of information are provided along with some supporting charts.

Fields Descriptions and related metrics
Max CPU utilization The maximum CPU utilization as a percentage.
Pertains to database/cpu/utilization.
Max memory utilization The maximum memory utilization as a percentage.
Pertains to database/memory/utilization.

The following table lists the insights and recommendations that the Cloud SQL overprovisioned instance recommender might generate to help you reduce costs. The subtypes are visible in the gcloud and API results.

Insights Recommendations
Based on the current CPU utilization trends, the instance is flagged as overprovisioned.
Subtype: LOW_CPU_UTILIZATION.
Reduce the number of vCPUs or switch to a machine with lower CPU.
Subtype: CHANGE_INSTANCE_SIZE
Based on the current memory utilization trends, the instance is flagged as overprovisioned.
Subtype: LOW_MEMORY_UTILIZATION.
Reduce the memory requirement or switch to a machine with lower memory.
CHANGE_INSTANCE_SIZE.

Evaluate the insights and recommendations carefully and do any of the following:

  • To go to the overview page of the instance, click View instance.

    Edit the instance, if required, to reduce the vCPUs or memory. Alternatively, switch to a machine type with fewer vCPUs and less memory. Rightsizing need not be exactly as recommended and is best done based on your judgment about the intended provisioning for the instance.

  • To dismiss the recommendation so that it's de-emphasized and appears in gray, click Dismiss.

  • To close the panel without applying or dismissing the recommendation, click Cancel.

You can also export these recommendations to BigQuery and then examine them using Data Studio or Looker.

What's next