Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
MySQL | PostgreSQL | SQL Server
Cette page explique comment gérer les bases de données avec un nombre élevé de connexions client simultanées et un nombre élevé de threads de connexion à la base de données. Cet outil de recommandation est appelé Reconfigurer les paramètres de connexion.
Chaque jour, cet outil de recommandation analyse les métriques pour les éléments suivants:
Nombre maximal de connexions à la base de données en suivant la valeur de l'indicateur max_used_connections. Si le nombre maximal de connexions depuis le redémarrage du serveur est de 80 % de la valeurmax_connections, Reconfigurer les paramètres de connexion vous recommande d'augmenter la valeur dumax_connections.
Nombre de nouveaux threads de connexion à la base de données par rapport au nombre de threads de connexion à la base de données existants. Si plus de 50 % des connexions génèrent de nouveaux threads au lieu de réutiliser des threads mis en cache, ou si la valeur de thread_cache_size est définie sur 0, la section Reconfigurer les paramètres de connexion vous recommande d'augmenter la valeur de thread_cache_size.
Pour obtenir les autorisations permettant d'afficher et d'utiliser les insights et les recommandations, assurez-vous de disposer des rôles IAM (Identity and Access Management) requis.
Dans la bannière Améliorez l'état de l'instance en analysant les problèmes et en agissant sur la base des recommandations, cliquez sur Développer les détails.
GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/recommenders/google.cloudsql.instance.PerformanceRecommender/recommendations
Remplacez les éléments suivants :
PROJECT_ID : ID de votre projet.
LOCATION : région où se trouvent vos instances, par exemple us-central1.
Afficher les insights et les recommandations détaillées
Pour afficher les insights et les recommandations détaillées, procédez comme suit :
Console
Effectuez l'une des opérations suivantes :
Sur la page Recommandations de performances, cliquez sur la fiche Recommandations de performances, puis sur Reconfigurer les paramètres de connexion.
Le panneau de recommandations s'affiche. Il contient des insights et des recommandations détaillées pour l'instance.
Sur la page Instances, cliquez sur Reconfigurer les paramètres de connexion.
La liste des instances n'affiche que les instances pour lesquelles la recommandation s'applique.
LOCATION : région où se trouvent vos instances, par exemple us-central1.
INSIGHT_SUBTYPE: définissez ce paramètre sur l'un des éléments suivants:
MYSQL_HIGH_NUMER_OF_CONNECTIONS : affiche des insights sur le nombre de connexions à la base de données pour votre instance.
MYSQL_HIGH_THREAD_CACHE_MISS_RATE : affiche des insights sur le nombre de nouveaux threads de connexion à la base de données sans utiliser le cache de threads pour votre instance.
GET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/insightTypes/google.cloudsql.instance.PerformanceInsight/insights
Remplacez les éléments suivants :
PROJECT_ID : ID de votre projet.
LOCATION : région où se trouvent vos instances, par exemple us-central1.
Appliquer la recommandation
Pour mettre en œuvre cette recommandation, effectuez l'une des opérations suivantes:
Pour appliquer la recommandation concernant la taille du cache de pool de threads de connexion, procédez comme suit :
Si la valeur de thread_cache_size est définie sur 0, activez le cache de thread en définissant ce flag sur une valeur supérieure à 0.
Si la valeur de thread_cache_size est supérieure à 0, augmentez la valeur de ce flag. thread_cache_size doit être équivalent au nombre moyen de connexions à la base de données. Augmentez la valeur de thread_cache_size si le nombre de nouveaux threads est supérieur au paramètre actuel.
Pour appliquer la recommandation de connexion à la base de données, augmentez la valeur de l'indicateur max_connections. La recommandation est mise à jour quotidiennement. Par conséquent, après avoir augmenté la valeur de cette option, attendez 24 heures avant de vérifier à nouveau la recommandation. Pour savoir comment augmenter la valeur de max_connections, consultez Nombre maximal de connexions simultanées.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[],[],null,["# Reconfigure connection settings\n\n\u003cbr /\u003e\n\nMySQL \\| PostgreSQL \\| SQL Server\n\n\u003cbr /\u003e\n\n|\n| **Preview**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| You can process personal data for this feature as outlined in the\n| [Cloud Data Processing\n| Addendum](/terms/data-processing-addendum), subject to the obligations and restrictions described in the agreement under\n| which you access Google Cloud.\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis page describes how to manage databases with a high number of simultaneous\nclient connections and a high number of database connection threads. This\n[recommender](/recommender/docs/recommenders) is called\n**Reconfigure connection settings**.\n\nEvery day, this recommender analyzes metrics for the following:\n\n- The peak number of database connections by tracking the value of\n the `max_used_connections` flag. If the maximum number of connections since\n the server restarted is 80% of the value `max_connections`, **Reconfigure\n connection settings** recommends that you increase the value of\n `max_connections` .\n\n For more information on increasing the value of `max_connections`, see\n [Maximum concurrent connections](/sql/docs/quotas#maximum_concurrent_connections).\n- The number of new database connection threads compared to the number of\n existing database connection threads. If more than 50% of connections result\n in new threads instead of reusing cached ones, or if the value of\n `thread_cache_size` is set to 0, then **Reconfigure connection settings**\n recommends that you increase the value of `thread_cache_size`.\n\n For more information on increasing the value of `max_connections`, see\n [Optimize high CPU utilization in instances](/sql/docs/mysql/optimize-cpu-usage).\n This feature is in [Preview](/products#product-launch-stages).\n\nPricing\n-------\n\nThe **Reconfigure connection settings** recommender is in the *Standard*\n[Recommender pricing tier](/recommender/pricing).\n\nBefore you begin\n----------------\n\n[Enable the Recommender API](/recommender/docs/enabling).\n\n### Required roles and permissions\n\nTo get the permissions to view and work with insights and recommendations,\nensure that you have the required [Identity and Access Management (IAM) roles](/sql/docs/mysql/project-access-control#roles).\n\nFor more information about IAM roles, see [IAM basic and predefined roles reference](/iam/docs/understanding-roles) and [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\u003cbr /\u003e\n\nList the recommendations\n------------------------\n\nTo list the recommendations, follow these steps: \n\n### Console\n\nTo list recommendations about instance performance, follow these steps:\n\n1. Go to the **Cloud SQL Instances** page.\n\n[Go to Cloud SQL Instances](https://console.cloud.google.com/sql/instances)\n\n1. On the **Improve instance health by investigating issues and acting on\n recommendations** banner, click **Expand Details**.\n\nAlternatively, follow these steps:\n\n1. Go to the **Recommendation Hub** . See also [Find and apply recommendations with the Recommendations](/recommender/docs/recommendation-hub/identify-configuration-problems).\n\n [Go to the Recommendation Hub](https://console.cloud.google.com/home/recommendations/)\n2. In the **All recommendations** card, click **Performance** .\n\n### gcloud\n\nRun the [`gcloud recommender recommendations list`](/sdk/gcloud/reference/recommender/recommendations/list) command as follows: \n\n```\ngcloud recommender recommendations list \\\n--project=PROJECT_ID \\\n--location=LOCATION \\\n--recommender=google.cloudsql.instance.PerformanceRecommender \\\n--filter=recommenderSubtype=MYSQL_RECONFIG_CONNECTIONS\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your project ID\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: a region where your instances are located, such as `us-central1`\n\n### API\n\nCall the [`recommendations.list`](/recommender/docs/reference/rest/v1/projects.locations.recommenders.recommendations/list) method as follows: \n\n```\nGET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/recommenders/google.cloudsql.instance.PerformanceRecommender/recommendations\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your project ID\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: a region where your instances are located, such as `us-central1`\n\nView insights and detailed recommendations\n------------------------------------------\n\nTo view insights and detailed recommendations, follow these steps: \n\n### Console\n\nDo one of the following:\n\n- On the **Performance Recommendations** page, click the **Performance\n recommendations** card and then click **Reconfigure connection settings**.\n The recommendation panel appears, which contains insights and detailed\n recommendations for the instance.\n\n- On the **Instances** page, click **Reconfigure connection settings**.\n The list of instances displays only those instances for which the\n recommendation applies.\n\n### gcloud\n\nRun the [`gcloud recommender insights list`](/sdk/gcloud/reference/recommender/insights/list) command as follows: \n\n```\n\ngcloud recommender insights list \\\n--project=PROJECT_ID \\\n--location=LOCATION \\\n--insight-type=google.cloudsql.instance.PerformanceInsight \\\n--filter=insightSubtype=INSIGHT_SUBTYPE\n\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your project ID\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: a region where your instances are located, such as `us-central1`\n- \u003cvar translate=\"no\"\u003eINSIGHT_SUBTYPE\u003c/var\u003e: set this parameter to one of the following:\n - `MYSQL_HIGH_NUMER_OF_CONNECTIONS`: display insights for the number of database connections for your instance\n - `MYSQL_HIGH_THREAD_CACHE_MISS_RATE`: display insights for the number of new database connection threads without using the thread cache for your instance\n\n### API\n\nCall the [`insights.list`](/recommender/docs/reference/rest/v1/projects.locations.insightTypes.insights/list) method as follows: \n\n```\n\nGET https://recommender.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/insightTypes/google.cloudsql.instance.PerformanceInsight/insights\n\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your project ID\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: a region where your instances are located, such as `us-central1`\n\nApply the recommendation\n------------------------\n\nTo implement this recommendation, do one of the following:\n\n- To apply the recommendation for the connection thread cache size, do one of\n the following:\n\n - If the value of `thread_cache_size` is set to 0, then enable the thread\n cache by setting this flag to a value greater than 0.\n\n - If the value of `thread_cache_size` is greater than 0, then increase the\n value of this flag. `thread_cache_size` should be equivalent to the average\n number of connections to the database. Increase the value of\n `thread_cache_size` if the number of new threads is higher than the current\n setting.\n\n- To apply the database connection recommendation, increase the value of the\n `max_connections` flag. The recommendation is updated daily, so after you\n increase the value of this flag, wait for 24 hours before checking the recommendation again. For more information on\n increasing the value of `max_connections`, see [Maximum concurrent connections](/sql/docs/quotas#maximum_concurrent_connections).\n\n| **Note:** Increasing `thread_cache_size` and `max_connections` requires more memory. After increasing these flags, monitor the memory usage.\n\nWhat's next\n-----------\n\n- [Google Cloud recommenders](/recommender/docs/recommenders)"]]