Database instances running with an allocation of memory that's either too low or too high might experience performance issues. Instances can sometimes run into out-of-memory (OOM) issues.
The max server memory (mb)
flag limits the amount of memory that Cloud SQL can allocate for its
internal pools. You can manually set a value for this flag, or omit the flag
and let Cloud SQL manage memory limits for you automatically.
If you don't enable the flag, then Cloud SQL manages the instance's memory limits for you automatically, based on the size of the RAM for your instance.
If you enable the flag and manually set a value for it, and later resize the instance, then Cloud SQL disables the flag, overrides the value previously given, and automatically manages the memory limits of the instance for you until a new
max server memory (mb)
value is provided.
Insufficient values for the flag can cause performance issues, while over-allocation can lead to instability, performance degradation, and database crashes.
Users are strongly encouraged to let Cloud SQL manage the instance's memory limits.
For more information, see SQL Server settings.
Pricing
The Maximum server memory recommender is in the Standard Recommender pricing tier.
Before you begin
Required roles and permissions
To get the permissions to view and work with insights and recommendations, ensure that you have the required Identity and Access Management (IAM) roles.
Task | Role |
---|---|
View recommendations |
recommender.cloudsqlViewer or
cloudsql.admin
|
Apply recommendations |
cloudsql.editor
or cloudsql.admin
|
List the recommendations
To list the recommendations, follow these steps:
Console
To list recommendations about instance performance, follow these steps:
- Go to the Cloud SQL Instances page.
- On the Improve instance health by investigating issues and acting on recommendations banner, click Expand Details.
Alternatively, follow these steps:
Go to the Recommendation Hub. See also Find and applyrecommendations with the Recommendations.
In the All recommendations card, click Performance .
gcloud
Run the gcloud recommender recommendations list
command as follows:
gcloud recommender recommendations list \ --project=PROJECT_ID \ --location=LOCATION \ --recommender=google.cloudsql.instance.PerformanceRecommender \ --filter=RECOMMENDER_SUBTYPE=SQLSERVER_USE_AUTOMATIC_MAX_SERVER_MEMORY_MANAGEMENT
Replace the following:
- PROJECT_ID: your project ID
- LOCATION: a region where your instances are located, such as
us-central1
API
Call the recommendations.list
method as follows:
GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/recommenders/google.cloudsql.instance.PerformanceRecommender/recommendations
Replace the following:
- PROJECT_ID: your project ID
- LOCATION: a region where your instances are located, such as
us-central1
View insights and detailed recommendations
To view insights and detailed recommendations, follow these steps:
Console
Do one of the following:
On the Performance Recommendations page, click the Performance recommendations card and then click Create indexes or reconfigure join settings. The recommendation panel appears, which contains insights and detailed recommendations for the instance.
On the Instances page, click Create indexes or reconfigure join settings. The list of instances displays only those instances for which the recommendation applies.
gcloud
Run the gcloud recommender insights list
command as follows:
gcloud recommender insights list \ --project=PROJECT_ID \ --location=LOCATION \ --insight-type=google.cloudsql.instance.PerformanceInsight \ --filter=INSIGHT_SUBTYPE=INSIGHT_SUBTYPE
Replace the following:
- PROJECT_ID: your project ID
- LOCATION: a region where your instances are located, such as
us-central1
- INSIGHT_SUBTYPE: the subtype used to verify whether allocated
memory is too low or too high. Acceptable values include
SQLSERVER_MAX_SERVER_MEMORY_TOO_LOW
andSQLSERVER_MAX_SERVER_MEMORY_TOO_HIGH
.
API
Call the insights.list
method as follows:
GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/insightTypes/google.cloudsql.instance.PerformanceInsight/insights
Replace the following:
- PROJECT_ID: your project ID
- LOCATION: a region where your instances are located, such as
us-central1
Apply the recommendation
Console
To implement this recommendation, do the following:
Locate the instance with the recommendation Server memory misconfigured. Click the recommendation to open it.
In the recommendation window, click Edit instance.
In the Flags and parameters section, locate and delete the Max server memory (mb) flag. Removing the flag lets Cloud SQL manage instance memory limits for you.