This topic describes the dedicated proxy feature of ApsaraDB RDS for MySQL. This feature provides advanced functions, such as read/write splitting, connection pool, and transaction splitting. You can enable this feature on your primary RDS instance.

Prerequisites

  • The primary RDS instance runs one of the following MySQL versions and RDS editions:
    • MySQL 8.0 with a minor engine version of 20191204 or later on RDS Enterprise Edition
    • MySQL 8.0 with a minor engine version of 20190915 or later on RDS High-availability Edition
    • MySQL 5.7 with a minor engine version of 20191128 or later on RDS Enterprise Edition
    • MySQL 5.7 with a minor engine version of 20190925 or later on RDS High-availability Edition
    • MySQL 5.6 with a minor engine version of 20200229 or later on RDS High-availability Edition
    Note You can log on to the ApsaraDB for RDS console and go to the Basic Information page of the primary RDS instance. In the Configuration Information section of the page, you can check whether the Upgrade Minor Version button exists. If the button exists, you can click it to view and update the minor engine version of the primary RDS instance. If the button does not exist, you are using the latest minor engine version. For more information, see Upgrade the minor engine version of an ApsaraDB RDS for MySQL instance.
    Upgrade Minor Engine Version
  • The primary RDS instance does not reside in Zone D of the China (Hangzhou) region, Zone A of the China (Beijing) region, or Finance Zone B of the China (Shenzhen) region.
    Note If the primary RDS instance resides in the preceding zones, you can migrate it to other zones before you enable the dedicated proxy feature. For more information, see Migrate an ApsaraDB RDS for MySQL instance across zones in the same region.

Background information

The dedicated proxy feature uses dedicated computing resources. This feature has the following benefits:

  • A unified proxy endpoint is provided to connect to all of the dedicated proxies that are enabled on the primary RDS instance. This reduces maintenance costs by relieving the need to update the endpoints on your application. The proxy endpoint remains valid unless you release the dedicated proxy instance. For example, you may enable read/write splitting during peak hours, but then release read-only instances and disable read/write splitting after peak hours. In these cases, you do not need to update the endpoints on your application because the proxy endpoint is still connected.
  • Dedicated proxies exclusively serve the primary RDS instance and its read-only RDS instances. You do not need to compete with other users for resources. This ensures service stability.
  • Dedicated proxies support scaling. You can enable more dedicated proxies based on your business requirements. This allows you to process more queries.

Billing

From January 15, 2020 to August 31, 2020, you were issued with one dedicated proxy free of charge. If you wanted to enable more dedicated proxies, you had to pay additional fees.

Since September 1, 2020, you must pay for every dedicated proxy that you enable. However, these dedicated proxies provide more powerful processing capabilities. In normal cases, each dedicated proxy can process up to 20,000 queries per second (QPS).

Note The discounts for the upgrade from shared proxy to dedicated proxy remain unchanged. For more information, see Upgrade an ApsaraDB RDS for MySQL instance from shared proxy to dedicated proxy.

Dedicated proxies support only the pay-as-you-go billing method. The following table lists the prices of dedicated proxies in different Alibaba Cloud regions.

Region Dedicated proxy
Name Code USD/hour/proxy
China (Hangzhou) cn-hangzhou 0.173
China (Shanghai) cn-shanghai 0.173
China (Qingdao) cn-qingdao 0.173
China (Beijing) cn-beijing 0.173
China (Zhangjiakou-Beijing Winter Olympics) cn-zhangjiakou 0.120
China (Hohhot) cn-huhehaote 0.173
China (Shenzhen) cn-shenzhen 0.173
China (Heyuan) cn-heyuan 0.173
China (Chengdu) cn-chengdu 0.173
China (Hong Kong) cn-hongkong 0.297
Japan (Tokyo) ap-northeast-1 0.288
India (Mumbai) ap-south-1 0.231
Singapore (Singapore) ap-southeast-1 0.271
Australia (Sydney) ap-southeast-2 0.273
Malaysia (Kuala Lumpur) ap-southeast-3 0.253
Indonesia (Jakarta) ap-southeast-5 0.271
Germany (Frankfurt) eu-central-1 0.243
UK (London) eu-west-1 0.280
UAE (Dubai) me-east-1 0.377
US (Virginia) us-east-1 0.237
US (Silicon Valley) us-west-1 0.284

Limits

  • Dedicated proxies do not support Secure Sockets Layer (SSL) encryption.
  • Dedicated proxies do not support compression protocols.
  • Dedicated proxies do not support VSwitch changes.

Precautions

  • While you change the specifications of the primary RDS instance or its read-only RDS instances, a transient connection error may occur.
  • If you connect your application to the proxy endpoint, all of the requests that are encapsulated in transactions are routed to the primary RDS instance. This applies if you do not enable the transaction splitting function.
  • If you use the proxy endpoint to implement read/write splitting, the read consistency of the requests that are not encapsulated in transactions cannot be guaranteed. If you require this read consistency, you must encapsulate these requests in transactions.
  • If you connect your application to the proxy endpoint, a SHOW PROCESSLIST statement is invoked to return a result set for each query. This result set consists of the query results from the primary RDS instance and its read-only RDS instances.
  • If you execute multi-statements or run stored procedures, the read/write splitting function is disabled and all subsequent requests over the current connection are routed to the primary RDS instance. To enable the read/write splitting function again, you must close the current connection and establish a new connection. For more information about multi-statements, see Multi-Statement.
  • The dedicated proxy feature supports the /*FORCE_MASTER*/ and /*FORCE_SLAVE*/ hints. However, requests that contain hints have the highest route priorities, and therefore these requests are not constrained by consistency or transaction limits. Before you use these hints, you must check whether these hints are suitable for your workloads. In addition, these hints cannot contain statements such as /*FORCE_SLAVE*/ set names utf8; . These statements can change environment variables. If you include these statements in these hints, errors may occur when you process your subsequent workloads.
    Note If you use the MySQL command line tool to establish a connection and execute these hints, you must add -c to the statements. Otherwise, the MySQL command line tool filters these hints.
  • After you enable the dedicated proxy feature, each connection is replicated to the primary RDS instance and its read-only RDS instances in compliance with the 1:N connection model. We recommend that you specify the same connection specifications for these instances. If these instances have different connection specifications, the number of connections allowed is subject to the lowest connection specifications among these instances.
  • If you create or restart a read-only RDS instance after you enable the dedicated proxy feature, only the requests over a new connection are routed to the new or restarted read-only RDS instance.
  • The max_prepared_stmt_count parameter must be set to the same value for the primary RDS instance and its read-only RDS instances.

Enable the dedicated proxy feature

  1. Log on to the ApsaraDB for RDS console.
  2. In the left-side navigation pane, click Instances. In the top navigation bar, select the region where your RDS instance resides.
    Select a region
  3. Find your RDS instance and click its ID.
  4. In the left-side navigation pane, click Database Proxy.
  5. Click Enable now.
    Enable the dedicated proxy feature
  6. Configure the Network Type and Proxy Instances parameters. Then, click Enable.
    Note
    • If RDS instances have different configurations, their default proxy endpoints are of different network types. For more information, see Create a proxy endpoint for a dedicated proxy.
    • We recommend that you specify the number of dedicated proxies as the rounded-up integer of the total number of CPU cores of your RDS instance and its read-only RDS instances divided by 8. A maximum of 60 dedicated proxies are supported

      For example, if your RDS instance has eight CPU cores and its read-only RDS instances have four CPU cores, the recommended number of dedicated proxies is 2 based on the following formula: (8 + 4)/8 = 1.5 (rounded up to 2).

    Enable the database proxy feature

Overview of the Database Proxy page

After the dedicated proxy feature is enabled, you can use the generated proxy endpoint to implement functions such as read/write splitting, connection pool, and transaction splitting.

Database Proxy page
Section Parameter Description
Proxy Endpoint Instance ID The ID of the dedicated proxy instance.
Enabled Proxies The number of dedicated proxies that are enabled on your RDS instance. You can enable more dedicated proxies. This allows you to process more queries.
Read/Write Splitting Specifies whether to enable the read/write splitting function for the proxy endpoint. For more information, see Read/write splitting.
Connection Pool Specifies whether to enable the connection pool function for the proxy endpoint. If you want to enable the connection pool function, this parameter also specifies the type of connection pool to enable. Valid values:
  • Enable Transaction Connection Pool: This is the default value. If tens of thousands of connections are established, select this value.
  • Enable Session Connection Pool: If only PHP short-lived connections are established, select this value.
  • Disable: If you want to disable the connection pool function, select this value.

For more information, see Connection pool.

Transaction Splitting Specifies whether to enable the transaction splitting function for the proxy endpoint. For more information, see Transaction splitting.
Note You can click Enable or Disable to the right of the Transaction Splitting parameter to enable or disable this function.
Endpoint The proxy endpoint that is generated after the dedicated proxy feature is enabled. This endpoint connects to all of the dedicated proxies that are enabled on your RDS instance. The read/write splitting function is also bound to this endpoint. You can also create, modify, or delete additional proxy endpoints. For more information, see Create a proxy endpoint for a dedicated proxy.
Port The port that is associated with the proxy endpoint.
Note To change the port, you can click Change Port to the right of the displayed port number. Valid values: 1000 to 5999.
Endpoint Type The network type of the proxy endpoint. You cannot change the network type.
Proxy Proxy Type The type of proxy that is enabled on your RDS instance. Only the Dedicated Proxy type is supported.
CPU and Memory The specifications that are provided per dedicated proxy. Only two CPU cores and 4 GB of memory (2 Cores, 4 GB) are supported.
Enabled Proxies The number of dedicated proxies that are enabled on your RDS instance. A maximum of 60 dedicated proxies are supported.
Note We recommend that you specify the number of dedicated proxies as the rounded-up integer of the total number of CPU cores of your RDS instance and its read-only RDS instances divided by 8.

For example, if your RDS instance has eight CPU cores and its read-only RDS instances have four CPU cores, the recommended number of dedicated proxies is 2 based on the following formula: (8 + 4)/8 = 1.5 (rounded up to 2).

Adjust the number of dedicated proxies

Note When you adjust the number of dedicated proxies, a transient connection error will occur. Make sure that your application is configured to automatically reconnect to your database system.
  1. Log on to the ApsaraDB for RDS console.
  2. In the left-side navigation pane, click Instances. In the top navigation bar, select the region where your RDS instance resides.
    Select a region
  3. Find your RDS instance and click its ID.
  4. In the left-side navigation pane, click Database Proxy.
  5. In the Proxy section of the Proxy Service tab, change the number in the Adjusted Proxies column and click Apply in the Adjustment Plan column.
    Adjust the number of dedicated proxies
  6. Set Applied At and click OK.
    Configure Proxy Resources

View the monitoring data of dedicated proxies

  1. Log on to the ApsaraDB for RDS console.
  2. In the left-side navigation pane, click Instances. In the top navigation bar, select the region where your RDS instance resides.
    Select a region
  3. Find your RDS instance and click its ID.
  4. In the left-side navigation pane, click Database Proxy.
  5. Click the Monitoring Data tab.
  6. Select a time range and view the CPU Utilization (%) metric for the selected time range.
    Note The CPU Utilization (%) metric indicates the CPU utilization that is contributed by the dedicated proxies.
    View the monitoring data of dedicated proxies

Update the minor engine version of the dedicated proxy instance

Note If you update the minor engine version of the dedicated proxy instance, the dedicated proxy instance will restart. The restart causes a transient connection error of about 30 seconds. The time when the dedicated proxy instance will restart depends on the Upgrade Time that you specify. You can select Upgrade Immediate or Upgrade within maintenance period. We recommend that you update the minor engine version of the dedicated proxy instance during off-peak hours. Otherwise, make sure that your application is configured to automatically reconnect to your database system.
  1. Log on to the ApsaraDB for RDS console.
  2. In the left-side navigation pane, click Instances. In the top navigation bar, select the region where your RDS instance resides.
    Select a region
  3. Find your RDS instance and click its ID.
  4. In the left-side navigation pane, click Database Proxy.
  5. In the Proxy Endpoint section of the Proxy Service tab, click Upgrade Dedicated Proxy Version.
    Upgrade Dedicated Proxy Version
  6. Specify Upgrade Time and click OK.

Disable the dedicated proxy feature

  1. Log on to the ApsaraDB for RDS console.
  2. In the left-side navigation pane, click Instances. In the top navigation bar, select the region where your RDS instance resides.
    Select a region
  3. Find your RDS instance and click its ID.
  4. In the left-side navigation pane, click Database Proxy.
  5. In the upper-right corner of the Proxy Service tab, click Disable Proxy Service.
    Disable Proxy Service
  6. In the message that appears, click OK.

FAQ

  • After I update my RDS instance that runs MySQL 5.7 to the latest minor engine version, why is the dedicated proxy feature still unavailable?

    Before you can use the dedicated proxy feature, you must disable the original read/write splitting function. This applies after you update your RDS instance that runs MySQL 5.7 to the latest minor engine version.

  • After I enable the dedicated proxy feature, do I need to use the proxy endpoint or the read/write splitting endpoint to implement read/write splitting?

    After you enable the dedicated proxy feature, the proxy endpoint and the read/write splitting endpoint are the same. The backend uses the proxy endpoint to implement read/write splitting.

Related operations

Operation Description
ModifyDBProxy Enables or disables the dedicated proxy feature on an ApsaraDB for RDS instance.
ModifyDBProxyInstance Modifies the settings of the dedicated proxy feature on an ApsaraDB for RDS instance.
DescribeDBProxy Queries details about the dedicated proxies that are enabled on an ApsaraDB for RDS instance.
DescribeDBProxyEndpoint Queries information about the proxy endpoint of an ApsaraDB for RDS instance.
ModifyDBProxyEndpoint Modifies information about the proxy endpoint of an ApsaraDB for RDS instance.
DescribeDBProxyPerformance Queries the performance of the dedicated proxies that are enabled on an ApsaraDB for RDS instance.
CreateDBProxyEndpointAddress Creates an endpoint that is used to connect to the dedicated proxies of an ApsaraDB for RDS instance.
ModifyDBProxyEndpointAddress Modifies the endpoint that is used to connect to the dedicated proxies of an ApsaraDB for RDS instance.
DeleteDBProxyEndpointAddress Deletes the endpoint that is used to connect to the dedicated proxies of an ApsaraDB for RDS instance.