All Products
Search
Document Center

ApsaraDB RDS:Enable the database proxy feature

Last Updated:Jul 17, 2024

The database proxy feature of ApsaraDB RDS for MySQL supports capabilities such as read/write splitting, persistent connections, and SSL encryption. This helps reduce the load on your primary ApsaraDB RDS for MySQL instance and improve the availability and security of the RDS instance. This topic describes how to enable the database proxy feature for an RDS instance in the ApsaraDB RDS console and by calling related API operations. This topic also describes the method to calculate the recommended specification of database proxies.

Prerequisites

Your RDS instance is a primary RDS instance and meets the following requirements.

  • Version requirements:

    Major engine version

    RDS edition

    Minor engine version

    MySQL 8.0

    RDS Enterprise Edition

    20191204 or later

    RDS High-availability Edition

    20190915 or later

    RDS Cluster Edition

    No requirements

    MySQL 5.7

    RDS Enterprise Edition

    20191128 or later

    RDS High-availability Edition

    20190925 or later

    RDS Cluster Edition

    No requirements

    MySQL 5.6

    RDS High-availability Edition

    20200229 or later

  • Region requirements: The RDS instance for which you want to enable the database proxy feature does not reside in Hangzhou Zone C or Hangzhou Zone D.

Note

You can go to the Basic Information page of your RDS instance to obtain the preceding information. In the Configuration Information section, you can check whether Upgrade Kernel Version is displayed. If Upgrade Kernel Version is displayed, click Upgrade Kernel Version to view the minor engine version of the RDS instance. If Upgrade Kernel Version is not displayed, your RDS instance runs the latest minor engine version. For more information, see Update the minor engine version.

Billing rules

  • General-purpose database proxies are provided free of charge.

  • Dedicated database proxies are charged based on the pay-as-you-go billing method. For more information, see Billing rules for database proxies.

Limits

  • If you enable the database proxy feature for your RDS instance, your RDS instance does not support compression protocols.

  • If you enable the database proxy feature for your RDS instance, your RDS instance does not support vSwitch changes.

Usage notes

  • If you use RDS Cluster Edition, you can use the primary and secondary nodes in your RDS cluster to implement read/write splitting. An RDS instance that runs RDS Cluster Edition is referred as an RDS cluster.

  • After the database proxy feature is enabled, we recommend that you do not migrate the primary RDS instance across zones. If you migrate the primary RDS instance across zones, the primary RDS instance and its database proxies are in different zones. This increases access latency and slows down responses.

    Note

    If a primary/secondary switchover is triggered due to service failures, the primary RDS instance and its database proxies are in different zones. To reduce access latency, you can perform a primary/secondary switchover to make sure that the primary RDS instance and its database proxies are in the same zone. For more information, see Switch workloads over between primary and secondary ApsaraDB RDS for MySQL instances.

Procedure

Note

This section describes how to enable or disable the database proxy feature for your RDS instance on the instance details page. You can also enable the database proxy feature when you create a read-only RDS instance for your RDS instance. For more information, see Create a read-only ApsaraDB RDS for MySQL instance.

Enable the database proxy feature

  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, find the RDS instance, and then click the instance ID.

  2. In the left-side navigation pane, click Database Proxy.

  3. Find the required database proxy type and click Enable Now.

    • General-purpose: General-purpose database proxies are provided free of charge. When you enable a general-purpose database proxy, the system automatically uses the recommended proxy specification. After the database proxy is enabled, you can change the proxy specification.

    • Dedicated: Dedicated database proxies are charged based on the pay-as-you-go billing method. When you enable a dedicated database proxy, you can configure the proxy specification.

      Note

      The recommended proxy specification is calculated by using the following formula:

      Recommended proxy specification = Recommended number of database proxies × Unit specification of a database proxy The unit specification of a database proxy is fixed as 2 CPU cores.

      The highest specification of a general-purpose database proxy is 16 CPU cores. The highest specification of a dedicated database proxy is 32 CPU cores. The following table describes how the recommended number of database proxies is calculated.

      Proxy type

      RDS instance that runs RDS High-availability Edition

      RDS instance that runs RDS Cluster Edition

      Recommended number of general-purpose database proxies

      (Number of CPU cores of the primary RDS instance + Number of CPU cores of all read-only RDS instances that belong to the primary RDS instance)/4. The result is rounded up.

      (Number of CPU cores of the primary node + Number of CPU cores of all secondary nodes that belong to the primary node)/4. The result is rounded up.

      Recommended number of dedicated database proxies

      (Number of CPU cores of the primary RDS instance + Number of CPU cores of all read-only RDS instances that belong to the primary RDS instance)/8. The result is rounded up.

      (Number of CPU cores of the primary node + Number of CPU cores of all secondary nodes that belong to the primary node)/8. The result is rounded up.

      For example, if your primary RDS instance that runs RDS High-availability Edition has 8 CPU cores and its read-only RDS instance has 4 CPU cores, the recommended number of dedicated database proxies is 2. The value is obtained based on the following calculation: (8 + 4)/8 = 1.5. The result 1.5 is rounded up to 2. The recommended specification of database proxies is 4 CPU cores. The value is obtained based on the following calculation: 2 × 2 = 4.

  4. Click OK.

    After you enable the database proxy feature, you can go to the Database Proxy page to view the basic information and connection information about the database proxy.

    Section/Tab

    Parameter

    Description

    Basic Info

    Primary Instance

    The ID of the RDS instance.

    Proxy Instance Status

    The status of the proxy instance.

    Proxy Type

    The type of the database proxy. Valid values: General-purpose and Dedicated. For more information about the differences between general-purpose database proxies and dedicated database proxies, see What are database proxies?

    Zone

    The zone of the proxy instance. By default, the proxy instance resides in the same zone as the primary RDS instance.

    Proxy Specifications

    The specification of the database proxy.

    The following calculation describes the relationship between the specification of database proxies and the number of database proxies: Specification of database proxies = Unit specification of a database proxy × Number of database proxies. In this calculation, the unit specification of a database proxy is fixed as 2 CPU cores. For example, if the number of database proxies is 3, the specification of the database proxies is 6 CPU cores. The value is obtained based on the following calculation: 2 x 3 = 6.

    Proxy Version

    The database proxy version.

    Connection Information

    Proxy Endpoint (Terminal) ID

    The ID of the database proxy endpoint. You can configure different connection settings for each database proxy endpoint.

    Note
    • Each RDS instance supports up to seven database proxy endpoints. You can apply for one internal endpoint and one public endpoint for each database proxy endpoint.

    • If you enable a database proxy for your RDS instance, the system assign a database proxy endpoint with default connection settings. You can use the database proxy endpoint to connect to the RDS instance. For more information about how to modify the connection settings, see Configure the connection settings for a database proxy endpoint.

    • You can move the pointer over the ID of the database proxy endpoint to view the connection settings of the database proxy endpoint. The connection settings include Read/Write Attributes and the information in the Read Weight Information section.

    Read/Write Attributes

    The read and write attributes of the database proxy. The value can be Read/Write and Read-only.

    For more information, see Configure the read and write attributes and the read weight of the database proxy.

    Internal Endpoint/Port

    The internal endpoint of the database proxy endpoint and the port that is associated with the database proxy endpoint.

    You can use the endpoint to connect to the RDS instance over an internal network and use the database proxy feature.

    Note
    • The internal endpoint is bound to the ID of the database proxy endpoint. You can use the database proxy feature by customizing connection settings for the database proxy endpoint. For more information, see Configure the connection settings for a database proxy endpoint.

    • You can click the image.png icon to the right of the endpoint to modify the prefix of the endpoint and the port that is associated with the endpoint. For more information, see Manage database proxy endpoints.

    Public Endpoint/Port

    The public endpoint of the database proxy endpoint and the port that is associated with the database proxy endpoint.

    You can use the endpoint to connect to the RDS instance over the Internet and use the database proxy feature.

    Note
    • The database proxy provides an internal endpoint by default. You can apply for a public endpoint.

    • After you apply for a public endpoint, you can click the image.png icon to the right of the endpoint to modify the prefix of the endpoint and the port that is associated with the endpoint. For more information, see Manage database proxy endpoints.

(Optional) Disable the database proxy feature

Usage notes

If you disable the database proxy feature, issues in the following aspects may occur:

  1. Read/write splitting: The database proxy feature is used to implement read/write splitting. If you disable the feature, the application can no longer automatically distinguish read requests from write requests or forward read requests to read-only RDS instances. As a result, all requests are sent to the primary RDS instance. This may cause heavy loads on the primary RDS instance and affect instance performance and stability.

  2. Connection management: The database proxy feature provides various capabilities, such as connection pool management and persistent connection. If you disable the feature, the database connections are managed by the application. This may increase the overheads to establish and destroy connections and affect performance.

  3. Security: The database proxy feature helps ensure data security by using multiple methods such as access control and security policy configuration. If you disable the feature, your RDS instance is exposed and can be exploited by attackers. We recommend that you reinforce the security of your RDS instance after you disable the feature.

  4. O&M: The database proxy feature can be used for monitoring, log collection, and fault detection. After you disable the feature, you may need to use other methods to perform the preceding operations. This increases the O&M complexity and workload.

  5. Performance: A direct database connection shortens the network link and improves communication efficiency within specific areas. However, the optimization capabilities of the database proxy feature, such as query caching and connection reuse, become unavailable. This negatively affects performance in high-concurrency scenarios.

  6. Compatibility: If an application relies on special capabilities or protocol translations provided by the database proxy feature, direct connections can cause compatibility issues.

  7. Failover and high availability: The database proxy feature can be used for fault detection and automatic failover. If you disable the feature, you must manually perform the preceding operations. This affects service availability.

Procedure

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

  2. In the left-side navigation pane, click Database Proxy.

  3. In the upper-right corner of the page that appears, click Disable Database Proxy.

  4. Click OK.

Related operations

Operation

Description

ModifyDBProxy

Modifies a database proxy. When you enable the database proxy feature for an RDS instance, you must set the ConfigDBProxyService parameter to Startup. You can configure other parameters based on your business requirements.

DescribeDBProxy

Queries the database proxy details of an RDS instance.