The database proxy feature of ApsaraDB RDS for MySQL supports capabilities such as read/write splitting, persistent connections, nearest access, transaction splitting, connection pooling, 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:
Database engine version
RDS edition
Minor engine version
MySQL 8.0
RDS High-availability Edition
20190915 or later
RDS Cluster Edition
No requirements
MySQL 5.7
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.
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.
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 to 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 proxy nodes are in different zones. This increases access latency and slows down responses.
NoteIf a primary/secondary switchover is triggered due to service failures, the primary RDS instance and its proxy nodes reside in different zones. To reduce access latency, you can perform a primary/secondary switchover or migrate the proxy nodes to make sure that the primary RDS instance and its proxy nodes are in the same zone. For more information, see Perform a manual primary/secondary switchover and Migrate database proxies across zones.
Procedure
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
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 ID of the instance.
In the left-side navigation pane, click Database Proxy.
Find the required database proxy type and click Enable Now.
In the Enable Database Proxy dialog box, configure the required parameters. The following table describes the parameters.
Parameter
Description
Proxy Type
The type of the database proxy. Valid values: General-purpose and Dedicated. For more information, see Types of database proxies.
Deployment Method
The deployment mode of proxy nodes. Valid values: Dual-zone Deployment and Single-zone Deployment. For more information, see Deployment architecture of proxy nodes.
NoteWe recommend that you use the dual-zone deployment mode to provide cross-zone disaster recovery capabilities and improve system availability.
Total Number of Nodes
The number of proxy nodes. A database proxy contains multiple proxy nodes.
If the database proxy contains two proxy nodes, the proxy nodes can be deployed in single-zone deployment or dual-zone deployment mode.
If the database proxy contains four proxy nodes, the proxy nodes are deployed in dual-zone deployment mode.
Zone
The zone in which the proxy node resides. We recommended that the database proxy resides in the same zone as the RDS instance.
CPU Cores for Single Proxy Node
ImportantThe specifications of proxy nodes in the same zone must be the same.
If two proxy nodes are deployed in dual-zone deployment mode, the specifications of the proxy nodes must be the same.
A general-purpose proxy node can have up to 8 CPU cores.
A dedicated proxy node can have up to 16 CPU cores.
You can refer to the following table to select an appropriate specification for a proxy node.
Zone of Database Proxy Endpoint
The zone of the database proxy endpoint. When you enable the database proxy feature, a database proxy endpoint is created by default. You must specify a zone for the database proxy endpoint. We recommend that you specify the same zone as the primary RDS instance.
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 Information
Primary Instance
The ID of the RDS instance.
Proxy Instance Status
The status of the database proxy.
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 database proxy. By default, the database proxy resides in the same zone as the primary RDS instance.
Proxy Specifications
The specification of the database proxy.
Relationship between the specification of the database proxy and the specifications of proxy nodes:
Specification of a database proxy = Specifications of all proxy nodes
.Relationship between the number of proxy nodes and the specification of the database proxy:
Number of proxy nodes = Specification of the database proxy/Specification of a proxy node
.
Proxy Version
The database proxy version.
NoteFor more information about the database proxy version, see Release notes for the database proxy version. For more information about how to upgrade the database proxy version of an RDS instance, see Upgrade the database proxy version.
Proxy Node
Node ID
The ID of the proxy node.
Zone
The zone ID of the proxy node.
CPU Cores on Proxy Node
The specification of the proxy node.
Connection Information
Proxy Endpoint (Terminal) ID
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. You can also configure connection policies for each database proxy endpoint to meet different requirements.
When you enable the database proxy feature for your RDS instance, the system assign a database proxy endpoint to the RDS instance. 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.
Read/Write Attributes
Read/Write (Read/Write Splitting): The database proxy endpoint connects to the primary RDS instance and its read-only RDS instances, and can receive write requests. This is the default value.
Read-only (Primary Instance Not Connected to Receive Write Requests): The database proxy endpoint connects only to read-only RDS instances and cannot receive write requests.
For more information, see Configure the read and write attributes and the read weight of the database proxy.
Nearest Access
The nearest access feature is supported only for the deployment mode in which four proxy nodes are deployed in two zones. For more information, see Configure the nearest access feature.
Network Settings
The zone, VPC, and vSwitch of the database proxy.
The vSwitch can be changed. Before you change a vSwitch, make sure that you understand the impacts of the vSwitch change. For more information, see Impacts. You can click Switch vSwitch, configure the Destination vSwitch and Change Time parameters, and then click OK to change the vSwitch.
Internal Endpoint/Port
The internal endpoint is bound to the ID of the database proxy endpoint. You can use the internal endpoint to connect to the RDS instance over an internal network and use the database proxy feature. For more information, see Configure the connection settings for a database proxy endpoint.
You can click the 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 public endpoint to connect to the RDS instance over the Internet and use the database proxy feature.
NoteThe 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 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:
Read/write splitting: If you use the database proxy feature to implement read/write splitting, the application can no longer automatically distinguish read requests from write requests or forward read requests to read-only RDS instances after your disable the feature. As a result, all requests are sent to the primary RDS instance. This may cause heavy loads on the primary RDS instance and affect the performance and stability of your database system.
Connections: If you use the database proxy endpoint to connect your application to an RDS instance, the application and the RDS instance are disconnected after you disable the database proxy feature.
Connection management: The database proxy feature provides various capabilities, such as connection pool management and persistent connections. If you disable the feature, you must create a program in your application to manage the database connections. This may increase the overheads to establish and destroy connections and affect performance.
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.
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.
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.
Compatibility: If an application relies on special capabilities or protocol translations provided by the database proxy feature, direct database connections may cause compatibility issues.
Failover and high availability: In specific scenarios, 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.
Instance connections: After you disable the database proxy feature, the database proxy endpoint (formerly proxy terminal) is released. Your application cannot connect to the RDS instance by using the internal or public endpoint of the database proxy endpoint and existing connections are interrupted. The endpoints of the RDS instance are not affected.
If you enable the database proxy feature after you disable the feature, the database proxy endpoints change.
Procedure
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.
In the left-side navigation pane, click Database Proxy.
In the upper-right corner of the page that appears, click Disable Database Proxy.
Click OK.
Related operations
Operation | Description |
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. | |
Queries the database proxy details of an RDS instance. |