All Products
Search
Document Center

ApsaraDB RDS:Use the transaction splitting feature

Last Updated:Jan 12, 2024

The database proxy feature for a primary ApsaraDB RDS for MySQL instance supports transaction splitting to ensure read/write consistency and to forward the read requests prior to the first write operation in transactions to read-only RDS instances. This reduces the loads on the primary RDS instance. This topic describes how to enable and disable transaction splitting.

Prerequisites

The database proxy feature is enabled. For more information, see Enable the database proxy feature.

Background information

The database proxy feature of ApsaraDB RDS for MySQL automatically sends all requests in a transaction to the primary RDS instance to ensure the accuracy of the transaction. In some cases, all requests are encapsulated in transactions that are not automatically committed. You can run the set autocommit=0; statement to disable the autocommit mode. As a result, the primary RDS instance is heavily loaded.

image.png

To resolve the preceding issue, you can use the transaction splitting capability of the database proxy feature. The transaction splitting capability offloads read requests in transactions from the primary RDS instance to its read-only RDS instance without modifying the code or configurations of applications. This improves the stability of the primary RDS instance.

After transaction splitting is enabled, if the default isolation level READ COMMITTED is used and the autocommit mode of transactions is disabled, the system starts a transaction only for write operations. In addition, before the transaction is started, the system routes all read requests to the read-only RDS instances by using a load balancer.

Note
  • Transaction splitting of the database proxy feature is automatically enabled.

  • Explicit transactions cannot be split. These explicit transactions include the transactions that are started by executing the BEGIN or START statement.

  • If transaction splitting is enabled, global consistency cannot be ensured. Before you enable the database proxy feature, make sure that transaction splitting is suitable for your workloads.

δΊ‹εŠ‘ζ‹†εˆ†

Procedure

You can enable or disable the transaction splitting feature based on your business requirements.

  1. 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.
  2. In the left-side navigation pane, click Database Proxy.

  3. In the Connection Information section, find the database proxy endpoint that you want to modify and click Modify Configuration in the Actions column.

  4. In the dialog box that appears, click Enable or Disable next to Transaction Splitting.

    Note

    After you enable or disable transaction splitting, the new setting is applied only to new connections.

Related operations

Operation

Description

DescribeDBProxy

Queries the details of a database proxy.

DescribeDBProxyEndpoint

Queries the information about a database proxy endpoint.

ModifyDBProxyEndpoint

Modifies the settings of a database proxy endpoint.