The database proxy for ApsaraDB RDS for MySQL provides read/write splitting, persistent connections, nearest access, transaction splitting, connection pooling, and SSL encryption to reduce primary instance load and improve availability and security. This topic describes how to enable the database proxy by using the ApsaraDB RDS console or API operations, and calculate recommended proxy specifications.
Prerequisites
The primary instance must meet the following requirements:
-
The primary instance must be an RDS High-availability Edition or RDS Cluster Edition instance that meets the version requirements in the following table. The database proxy is not supported on RDS Basic Edition instances. You can upgrade the instance to RDS High-availability Edition or upgrade it to RDS Cluster Edition and then enable the database proxy.
Database engine and version
Instance 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: The instance must not be in Zone C or Zone D of the China (Hangzhou) region.
You can view this information on the Basic Information page of the instance. If an Upgrade Minor Engine Version button is displayed in the Configuration Information section, you can click the button to view the current version. If the button is not displayed, the instance is already on the latest version. Upgrade a minor engine version.
Billing
-
General-purpose database proxies are free of charge.
-
Dedicated database proxies are pay-as-you-go. Database proxy billing.
Limitations
The database proxy does not support compression protocols.
Usage notes
-
RDS Cluster Edition instances use primary and secondary nodes for read/write splitting.
-
RDS High-availability Edition instances require a read-only instance and the database proxy enabled for read/write splitting.
-
After enabling the database proxy, do not migrate the primary instance to a different zone. Cross-zone migration separates the instance from the proxy and increases latency.
NoteIf a primary/secondary switchover occurs due to a service failure, you can manually perform a primary/secondary switchover or migrate the database proxy to another zone to align the primary instance and proxy zones and reduce latency.
Procedure
You can also enable the database proxy when you create a read-only instance. Create a read-only ApsaraDB RDS for MySQL instance.
Enable the database proxy
-
Go to the Instances page, select the region of your instance, and click the instance ID.
-
In the left navigation bar, click Database Proxy.
-
Under the target proxy type, click Enable Now.
-
In the Enable Database Proxy dialog box, configure the following proxy information.
Parameter
Description
Proxy Type
The proxy type: general-purpose or dedicated. Proxy types.
Deployment Method
The deployment method: dual-zone or single-zone. Proxy deployment architecture.
NoteDual-zone deployment is recommended for cross-zone disaster recovery and higher availability.
Total Number of Nodes
Number of proxy nodes:
-
2: Available for single-zone and dual-zone deployments.
-
4: Available only for dual-zone deployments.
Zone
The zone for proxy nodes. Deploy the proxy in the same zone as the RDS instance.
CPU Cores for Single Proxy Node
Important-
Proxy nodes in the same zone must use the same specifications.
-
In a dual-zone deployment with a total of two proxy nodes, both proxy nodes must use the same specifications.
-
general-purpose: 1 to 8 cores.
-
dedicated: 1 to 16 cores.
Select specifications based on the following guidelines.
Zone of Database Proxy Endpoint
A proxy endpoint is created by default. You must specify a zone for the endpoint — select the same zone as the primary instance.
-
-
Click OK.
When basic information and connection information appear on the Database Proxy tab, the database proxy is enabled.
Category
Parameter
Description
Basic Information
Primary Instance
The ID of the RDS for MySQL instance.
Proxy Instance Status
The running status of the proxy instance.
Proxy Type
The proxy type: general-purpose or dedicated. Proxy types.
Zone
The zone of the proxy instance, same as the primary zone of the primary instance.
Proxy Specifications
The current proxy specifications.
-
Relationship between proxy specifications and single-node specifications:
Total proxy specifications = SUM(Specifications of all proxy nodes). -
Relationship between number of proxy nodes and proxy specifications:
Number of proxy nodes = Total proxy specifications / Specifications of a single proxy node.
Proxy Version
The minor engine version of the proxy.
NoteFor version updates, see Database proxy minor version release notes. To upgrade, see Upgrade the minor engine version of a database proxy.
Node Type
Node ID
The ID of the proxy node.
Zone
The zone of the proxy node.
CPU Cores on Proxy Node
The specifications of a single proxy node.
Connection Information
Proxy Endpoint (Terminal) ID
-
Each RDS for MySQL instance supports 1 to 7 proxy endpoints. Each endpoint supports one internal endpoint and one public endpoint, with independent access policies.
-
A proxy endpoint is automatically assigned when you enable the proxy. To modify it, see Configure access policies for a database proxy endpoint.
Read/Write Attributes
-
Read/Write (read/write splitting): Connects to both the primary and read-only instances. This attribute allows the proxy to accept write requests.
-
Read-only: Connects only to read-only instances and does not accept write requests.
Nearest Access
Nearest access requires dual-zone deployment with four proxy nodes. Configure nearest access.
Network Information
The zone, VPC, and vSwitch of the database proxy.
You can change the vSwitch. Before you change the vSwitch, understand the impacts. Click Switch vSwitch, select the Destination vSwitch and Change Time, and click OK.
Internal Endpoint/Port
-
This internal endpoint is bound to the proxy endpoint ID. Use it to connect over the internal network with the database proxy. Configure access policies for a database proxy endpoint.
-
Click the
icon next to the endpoint to modify the prefix and port. Configure a database proxy endpoint.
Public Endpoint/Port
The public endpoint and port of the proxy.
Use this endpoint to connect over the internet with the database proxy.
Note-
The database proxy provides an internal endpoint by default. You can apply for a public endpoint.
-
After you apply for a public endpoint, click the
icon next to the endpoint to modify the prefix and port. Configure a database proxy endpoint.
-
(Optional) Disable the database proxy
Impacts of disabling
Disabling the database proxy can have the following impacts:
-
Read/write splitting failure: Read requests can no longer be routed to read-only instances. All requests go to the primary instance, which may cause high load.
-
Connection failure: All existing connections through the proxy are terminated.
-
Connection management issues: Features like connection pooling and persistent connections are removed. Your application must manage connections directly.
-
Security risks: The proxy provides access control and security policies. Disabling it can directly expose the database instance.
-
Increased operational complexity: Built-in monitoring, logging, and fault detection are removed. You must implement these separately.
-
Performance impact: While eliminating a network hop, losing proxy optimizations like query caching and connection reuse can degrade performance under high concurrency.
-
Compatibility issues: Applications relying on proxy-specific features or protocol translations may encounter issues with direct connections.
-
Failover and high availability: In some scenarios, the proxy assists with fault detection and automatic failover. Without it, you must handle these manually.
-
Database connections: The proxy endpoint is released and all connections through it are terminated. Direct connections to the RDS instance are not affected.
-
Re-enabling the proxy creates a new proxy endpoint.
Procedure
-
Go to the Instances page, select the region of your instance, and click the instance ID.
-
In the left navigation bar, click Database Proxy.
-
In the upper-right corner of the page, click Disable Database Proxy.
-
Click OK.
API reference
|
API |
Description |
|
To enable the database proxy, set the ConfigDBProxyService parameter to Startup. Configure other parameters as needed. |
|
|
Queries database proxy details for an ApsaraDB RDS for MySQL instance. |