This topic introduces the database proxies of ApsaraDB RDS for MySQL.
ApsaraDB RDS for MySQL provides two types of database proxies: dedicated proxies and shared proxies. A database proxy resides between a database system and an application. The database proxy receives requests from the application and routes the requests to the primary RDS instance and read-only RDS instances in the database system. The database proxy is easy to use and maintain and provides high availability and high performance. The dedicated proxy also provides advanced features, such as automatic read/write splitting, transaction splitting, and connection pooling.
Only dedicated proxies are supported. For more information, see the "Appendix: Introduction to shared proxies" section of this topic.
Scenarios
The primary RDS instance is heavily loaded due to a large number of requests that are encapsulated in transactions.
The primary RDS instance is heavily loaded due to an excessively large number of connections.
Most of your workloads require short-lived connections.
Read/write splitting is required.
Read-only workloads and workloads that need to be isolated.
NoteFor example, your database system consists of one primary RDS instance and four read-only RDS instances, and you have two applications, Application A and Application B. Application A initiates only read requests, and Application B initiates both read and write requests. In this case, you can use two read-only instances to create Proxy Terminal A with the Read-only attribute. Then, you can use the other two read-only instances to create Proxy Terminal B with the Read/Write attribute. This way, Application A and Application B are isolated from each other in your database system.
Introduction to proxy terminals
Proxy terminals are developed by Alibaba Cloud. You can use proxy terminals to customize the endpoints that are used to connect to an RDS instance. Each RDS instance supports up to seven proxy terminals. You can modify the read and write attributes of each proxy terminal based on your various business requirements.
Read and write attributes
You can set the read and write attributes of each proxy terminal.
Read/Write: This attribute is used to support the read/write splitting feature. The read/write splitting feature allows you to linearly scale the volume of workloads that can be processed by your database system. For more information, see What is read/write splitting?
If you select this attribute for a proxy terminal, you must make sure that the proxy terminal is associated with at least one primary RDS instance and one read-only RDS instance. All write requests are routed to the primary RDS instance. In this case, the proxy terminal supports features such as transaction splitting and connection pool. For more information, see Use the transaction splitting feature on an ApsaraDB RDS for MySQL instance and Set the connection pool type of an ApsaraDB RDS for MySQL instance.
Read-only: This attribute is used to process only read requests. For example, if your application provides only the report service, you can select this attribute.
If you select this attribute for a proxy terminal, you must make sure that the proxy terminal is associated with at least one read-only RDS instance. The proxy terminal does not route requests to the primary RDS instance. In addition, the proxy terminal does not support features such as transaction splitting and connection pool. For more information, see Use the transaction splitting feature on an ApsaraDB RDS for MySQL instance and Set the connection pool type of an ApsaraDB RDS for MySQL instance.
If you select the Read-only attribute for a proxy terminal, the proxy terminal assigns connections to the associated read-only RDS instances based on a round-robin algorithm. Each database client is assigned only one connection to one read-only RDS instance. The connection to the primary RDS instance is not assigned by the proxy terminal. The total number of available connections is the sum of connections that are established to all the read-only RDS instances.
For more information about how to modify the read and write attributes of a proxy terminal, see Enable the dedicated proxy feature for an ApsaraDB RDS for MySQL instance.
Overview
Database proxies provide the following features:
You can perform various operations on the Proxy tab. For example, you can upgrade the dedicated proxy version and create a proxy endpoint on this tab.
Type
Parameter
Description
Proxy Endpoint
Status
The status of the dedicated proxy.
Instance ID
The ID of the RDS instance.
Associated Proxy Instances
The number of proxy instances that are associated with the dedicated proxy. You can increase the processing capability of the dedicated proxy by enabling more proxy instances.
Endpoint
Proxy Terminal
The name of a proxy terminal. You can create multiple proxy endpoints for each proxy terminal. For more information, see What is read/write splitting?
Endpoint
The endpoint that is used to connect to the dedicated proxy. The dedicated proxy provides a default proxy endpoint to which the proxy terminal feature is bound. You can create, modify, or delete a proxy endpoint. For more information, see Manage the dedicated proxy endpoints of an ApsaraDB RDS for MySQL instance.
Port
The port number that is bound to a proxy endpoint.
NoteTo change a port number, you must find the proxy endpoint to which the port number is bound and click Change on the right. A valid port number ranges from 1000 to 5999.
Network Type
The network type of a proxy endpoint. You cannot change the network type of a proxy endpoint.
Proxy Instance
Proxy Type
Only Dedicated Proxy is supported.
CPU and Memory
The specifications that are provided per proxy instance. Each proxy instance can only have 2 cores and 4 GB of memory.
Enabled Proxy Instance
The number of proxy instances that are enabled for your RDS instance. ApsaraDB RDS can balance the loads among the proxy instances that are enabled. You can enable up to 16 proxy instances for your RDS instance.
NoteWe recommend that you set the number of proxy instances to
one-eighth of the total number of cores that are configured for your RDS instance and read-only RDS instances
. If the result is not an integer, you must round the result up to the nearest integer. Up to 16 proxy instances are supported.For example, if your RDS instance has 8 cores and read-only RDS instances have 4 cores, the recommended number of proxy instances is 2 based on the following calculation:
(8 + 4)/8 = 1.5
. The result 1.5 is rounded up to 2.Proxy terminal (original read/write splitting)
ApsaraDB RDS automatically routes read and write requests to the proxy endpoints that you configure. Then, these endpoints route the read and write requests to the primary RDS instance and read-only RDS instances based on the read weights of these instances. For more information, see What is read/write splitting?
Connection pool: This feature is used to mitigate the heavy loads on your database system. Heavy load issues are caused by excessive connections or frequent short-lived connections such as PHP-based connections. For more information, see Set the connection pool type of an ApsaraDB RDS for MySQL instance.
Transaction splitting: This feature allows ApsaraDB RDS to route the read requests prior to write operations within a transaction to the read-only RDS instances. This reduces the loads on your primary RDS instance. For more information, see Use the transaction splitting feature on an ApsaraDB RDS for MySQL instance.
You can view the CPU utilization for the proxy instances that are enabled. The CPU utilization information helps you obtain the loads on the proxy instances and adjust the number of proxy instances based on the monitoring data. For more information, see View the proxy monitoring data of an ApsaraDB RDS for MySQL instance.
SSL encryption: This feature is used to encrypt the data that is destined for the protected proxy endpoint. This ensures the security of data in transit. For more information, see Configure SSL encryption for a proxy endpoint on an ApsaraDB RDS for MySQL instance.
Usage notes
For more information, see Usage notes for database proxies.
How to enable dedicated proxies
For more information, see Enable and configure the dedicated proxy feature for an ApsaraDB RDS for MySQL instance.
Appendix: Introduction to shared proxies
ApsaraDB RDS for MySQL provides two types of proxies: dedicated proxies and shared proxies.
A shared proxy is also called a multi-tenant proxy. A shared proxy allows the database systems of different users to share proxy computing resources. In this case, these database systems may compete for proxy computing resources. This decreases the stability of the shared proxy. In addition, a shared proxy does not support the advanced features that are provided by the dedicated proxy. These advanced features include connection pool, SSL encryption, and transaction splitting. However, a shared proxy supports read/write splitting. The network type of a read/write splitting endpoint changes with the network type of the primary RDS instance. For more information, see Change the network type of an ApsaraDB RDS for MySQL instance. Shared proxies are no longer available. For more information, see [Notice] End of updates and maintenance for the shared proxy feature.
A dedicated proxy is also called a single-tenant proxy. A dedicated proxy allows your database system to use dedicated proxy computing resources. Therefore, a dedicated proxy has the following benefits over a shared proxy:
The dedicated proxy provides higher stability.
The dedicated proxy provides higher isolation.
The dedicated proxy provides better performance. A maximum of 16 proxy instances can be created for each RDS instance. A SysBench test shows that each proxy instance supports 20,000 to 50,000 queries per second (QPS) in online transaction processing (OLTP) scenarios. We recommend that you estimate the maximum QPS that is supported by your RDS instance based on your actual stress test results.
NoteThe maximum number of connections to the dedicated proxy is not limited. This number varies based on the specifications of the primary and read-only RDS instances in your database system.
The dedicated proxy supports scaling. You can increase the number of proxy instances based on your business requirements. For more information, see Adjust the number of dedicated proxies on an ApsaraDB RDS for MySQL instance.
The dedicated proxy supports performance monitoring. You can adjust the number of proxy instances based on the monitoring data and your business planning. For more information, see View the monitoring data of dedicated proxies on an ApsaraDB RDS for MySQL instance.
If you change the network type of a primary RDS instance, the network type of the read/write splitting endpoint remains unchanged. For more information, see Change the network type of an ApsaraDB RDS for MySQL instance and What is read/write splitting?
A unified proxy endpoint is provided. This eliminates the need to modify the endpoint information on your application and reduces maintenance costs. The proxy endpoint remains valid until you release the proxy instances. For more information, see Manage the dedicated proxy endpoints of an ApsaraDB RDS for MySQL instance. The proxy endpoint remains connected unless you release the enabled proxy instances. For example, you can enable read/write splitting during peak hours and then disable read/write splitting and release read-only RDS instances during off-peak hours. In these cases, you do not need to update the endpoints on your application because the proxy endpoint remains connected.
The dedicated proxy supports automatic read/write splitting. This reduces maintenance costs. For more information, see Enable the read/write splitting feature for an ApsaraDB RDS for MySQL instance. In normal cases, to implement read/write splitting, you must manually add the endpoints of the primary and read-only RDS instances to your application. This applies if the read-only RDS instances are available. If you enable the dedicated proxy feature, you need to add only a unified proxy endpoint to your application. This way, all the requests from your application are sent to the proxy endpoint. Then, the proxy endpoint routes read requests to the read-only RDS instances and write requests to the primary RDS instance based on the read weights of these instances. You do not need to update the configuration data on your application even if you create more read-only RDS instances or if you delete existing read-only RDS instances.
The dedicated proxy provides more advanced features, such as connection pooling and transaction splitting. For more information, see Set the connection pool type of an ApsaraDB RDS for MySQL instance and Enable the transaction splitting feature for an ApsaraDB RDS for MySQL instance.
Shared proxies are not supported for new RDS instances due to the known limits. Alibaba Cloud continues to provide support for the shared proxies of existing RDS instances. If the shared proxy of your RDS instance is enabled, we recommend that you upgrade the instance from shared proxy to dedicated proxy. This allows you to use more advanced features. For more information, see Upgrade the database proxy of an ApsaraDB RDS for MySQL instance from a shared proxy to a dedicated proxy.