Before using the database proxy for ApsaraDB RDS for MySQL, review these notes to avoid unexpected behavior in your application.
Billing
General-purpose Edition proxies are free. Dedicated proxies, read-only instances, and primary instances are billed separately.
If you release the primary instance, the database proxy is automatically released and no charges apply to the dedicated proxy after release.
Connection model
The database proxy uses a 1:N connection model: when your application connects to the proxy, the proxy establishes connections to the primary instance and all configured read-only instances simultaneously.
The proxy itself does not limit the maximum number of connections — this limit is determined by the specifications of the backend database nodes. If transaction-level connection pooling is disabled, each client connection creates a corresponding connection on the primary instance and on every read-only instance. Keep the maximum connection specifications for the primary and read-only instances as consistent as possible. Otherwise, the effective connection limit for your application is set by the instance with the lowest connection limit.
The connection pool feature is enabled by default, which may cause show processlist to display idle user connections. When connected through a proxy endpoint, show processlist merges and returns results from all nodes.
Conditions that lock routing to the primary instance
Certain conditions cause the proxy to route all subsequent requests on the current connection to the primary instance, bypassing read/write splitting. To resume read/write splitting after any of the following conditions, close the current connection and establish a new one.
| Condition | Description | How to mitigate |
|---|---|---|
| Transaction splitting disabled | All transaction requests go to the primary instance. | Enable transaction splitting in the proxy settings. |
| Multi-statement execution | A multi-statement query is executed. | Rewrite queries to use single statements where possible. |
| Stored procedure call | A stored procedure is called. | Reconnect after the stored procedure completes. |
Read/write splitting
Read consistency for non-transactional reads is not guaranteed when using a proxy endpoint for read/write splitting. To ensure read consistency, encapsulate read requests in a transaction or use hint syntax.
When using hint statements with the MySQL command line, include the -c option. Without it, the MySQL command-line tool silently filters out the hints. For more information, see Use hint syntax.
Read-only instance operations
Adding or restarting a read-only instance: After you add a read-only instance to a proxy endpoint or restart a connected read-only instance, requests from both new and existing connections are routed to the new or restarted instance.
Removing a read-only instance: Statements running on that instance fail immediately. To take a read-only instance offline without disrupting your application, upgrade the proxy minor engine version to 2.8.41 or later and set the read/write attribute of the proxy to Read/Write before removing the instance. For upgrade instructions, see Upgrade the minor engine version of a database proxy. To configure weights, see Configure read/write attributes and read weights.
Instance switchover
If the persistent connections feature is not enabled, changing the configuration of the primary instance or a read-only instance may trigger an instance switchover. For more information about the effects of a switchover, see Effects of an instance switchover.
If the primary instance is locked, proxy instances at version 2.9.5 or later are not released — they continue to process read requests but cannot process write requests.
Limitations
| Area | Limitation |
|---|---|
| Protocol | Proxy endpoints do not support the compression protocol. |
| Parameter parity | For High-availability Edition instances, max_prepared_stmt_count must have the same value on the primary instance and all read-only instances. |
| VPC and vSwitch | The proxy does not support switching Virtual Private Clouds (VPCs) or vSwitches. Modifying the primary instance's VPC does not change the proxy's VPC. The proxy can still communicate with the primary instance, but the proxy endpoint becomes unreachable through the modified VPC. |
| CIDR format | When using a privileged account to configure an account's host range, the proxy supports CIDR blocks in the 10.1.2.% format. Configuring the proxy's CIDR block as 10.1.2.0/24 is not supported. |
| IP whitelist | The proxy shares the IP whitelist of the primary instance. Updating the primary instance's IP whitelist automatically updates the proxy's IP whitelist. |
Binary logging over the proxy
In high-latency networks, subscribing to binary logging (Binlog) through a proxy endpoint can cause Binlog Dump network throughput to become a performance bottleneck, leading to replication delay in downstream systems. Pull Binlog data by configuring a direct connection to the database node in your application or service instead.
Nearest access feature
Migrating the zone may invalidate the nearest access feature for some zones. After migration, the new zone is accessible by default, and the nearest access feature for the original zone becomes invalid. If you configure the target zone of a proxy endpoint to a zone different from the default zone, the nearest access feature for that zone also becomes invalid.
The following table shows example scenarios.
| Scenario | Current proxy instance zone | Proxy endpoint | Nearest access | Target proxy instance zone | Default proxy endpoint zone | Target proxy endpoint zone | Nearest access after migration |
|---|---|---|---|---|---|---|---|
Scenario 1: Migrate from Zone A + Zone B to Zone A + Zone C | Zone A | Proxy endpoint a | Zone A | Zone A | Zone A | Zone A | Zone A |
| Zone C | Invalid | ||||||
| Zone B | Proxy endpoint b | Zone B | Zone C | Zone C | Zone C | Zone C | |
| Zone D | Invalid | ||||||
Scenario 2: Migrate from Zone A + Zone B to Zone C + Zone D | Zone A | Proxy endpoint a | Zone A | Zone C | Zone C | Zone C | Zone C |
| Zone E | Invalid | ||||||
| Zone B | Proxy endpoint b | Zone B | Zone D | Zone D | Zone D | Zone D | |
| Zone E | Invalid |
The nearest access feature is supported only for Deployment Mode 1 of dedicated proxies. If this feature is enabled and you want to switch to a general-purpose proxy or a different deployment mode, disable the nearest access feature first. For instructions, see Set up nearest access. For more information about proxy deployment architectures, see Proxy deployment architecture.