All Products
Search
Document Center

ApsaraDB RDS:Modify the parameters that specify the maximum number of connections

Last Updated:Apr 01, 2024

This topic describes how to modify the parameters that specify the maximum number of connections to an ApsaraDB RDS for MySQL instance.

Background

To process a large number of concurrent connections and improve performance, you can modify the parameters that specify the maximum number of connections to the RDS instance in the ApsaraDB RDS console or by calling an API operation.

Scenarios

If the number of connections significantly changes, you can modify the parameters that specify the maximum number of connections to meet your business requirements. For example, your gaming application uses short-lived connections. When the application is launched or updated, the number of connections significantly increases in a short period of time. In this case, you can modify the parameters that specify the maximum number of connections to meet your business requirements.

Prerequisites

The RDS instance meets the following requirements:

  • The RDS instance runs MySQL.

  • The RDS instance runs RDS High-availability Edition, RDS Basic Edition, or RDS Cluster Edition.

Note

You can go to the Basic Information page of the RDS instance to view the preceding information.

Parameters

Two parameters are used to specify the maximum number of connections.

  • max_user_connections: the maximum number of connections that can be established by an account. The value of this parameter ranges from 10 to 208000. If the number of connections that are established by an account exceeds the upper limit, the has more than 'max_user_connections' or has exceeded the 'max_user_connections' error message is displayed, and new connections cannot be established.

  • max_connections: the maximum number of connections that can be established by all accounts. The value of this parameter ranges from 1 to 208000. If the number of connections that are established by all accounts exceeds the upper limit, the too many connections error message is displayed, and new connections cannot be established.

Impacts

Connections consume memory resources. If a large number of connections are established, a large number of system resources are consumed. Proceed with caution. If the max_connections parameter is set to a large value, out of memory (OOM) errors may occur. We recommend that you set this parameter to the maximum number of connections that are supported by the instance type of your RDS instance. This ensures the stability of your RDS instance.

Usage notes

  • After you change the value of the max_connections parameter, the value that is displayed for this parameter in the Running Parameter Value column on the Parameters page of your RDS instance is greater than the value that you specified. This is because the value in the Running Parameter Value column counts the number of connections reserved for routine O&M. The value of the Maximum Connections parameter in the Configuration Information section of the Basic Information page is the same as the value that you specified for the max_connections parameter.

  • When you restart the RDS instance, the maximum value of the max_connections parameter is affected by the open_files_limit parameter. In this case, the actual runtime value of the max_connections parameter is calculated by using the following formula: min{(open_files_limit - 810),(User-defined value or the maximum number of connections that are supported by the instance type + Number of connections reserved for routine O&M)}.

    The default value of the open_files_limit parameter is 655350. When you set the max_connections parameter to a value that is greater than 654540, we recommend that you change the value of the open_files_limit parameter in the ApsaraDB RDS console. This way, the max_connections parameter is not affected by the open_files_limit parameter when you restart your RDS instance. The value that you specified for the max_connections parameter counts the number of connections reserved for routine O&M. If you change the value of the open_files_limit static parameter, you must restart your RDS instance for the modification to take effect.

Modify the parameters in the ApsaraDB RDS console

  1. Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which your RDS instance resides. Then, find the RDS instance and click the instance ID.

  2. In the left-side navigation pane of the page that appears, click Parameters.

  3. On the Editable Parameters tab, find the max_user_connections or max_connections parameter and click the image icon in the Running Parameter Value column of the parameter. In the dialog box that appears, change the value and click OK.

  4. Click Apply Changes. In the dialog box that appears, select a time range at which you want the new value to take effect and click OK.

    Note

    The modifications of the max_connections and max_user_connections parameters immediately take effect. You do not need to restart your RDS instance.

Modify the parameters by calling an API operation

Sample requests

In this example, the ModifyParameter operation is called to change the values of the max_connections and max_user_connections parameters. The value of the max_connections parameter is changed to 2000, and the value of the max_user_connections parameter is changed to 500.

http(s)://rds.aliyuncs.com/?Action=ModifyParameter
&DBInstanceId=rm-gs5v9xajylz45****
&Parameters={"max_connections":"2000","max_user_connections":"500"}
&<Common request parameters>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json
{
  "RequestId" : "542BB8D6-4268-45CC-A557-B03EFD7AB30A"
  } 

Verify the modification

  1. Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which your RDS instance resides. Then, find the RDS instance and click the instance ID.

  2. In the left-side navigation pane of the page that appears, click Parameters.

  3. On the Edit History tab, check whether the new values of the parameters take effect.

    image

FAQ

  • I do not modify the max_connections parameter for my RDS instance. Why is the value in the Running Parameter Value column of the parameter on the Parameters page greater than the maximum number of connections that are supported by the instance type of the RDS instance?

    The value in the Running Parameter Value column of the parameter on the Parameters page counts the number of connections that are reserved for routine O&M.

  • After I modify the max_connections parameter and the modification takes effect, why is the value in the Running Parameter Value column greater than the value that I specified?

    The value in the Running Parameter Value column of the parameter on the Parameters page counts the number of connections that are reserved for routine O&M. The maximum number of connections that are allowed to the RDS instance is subject to the value of the Maximum Connections parameter in the Configuration Information section of the Basic Information page.