This topic describes how to enable the transaction splitting feature for an ApsaraDB RDS for MySQL instance. This feature allows ApsaraDB RDS to route the read requests prior to write operations in a transaction to the read-only RDS instances of your database system. This reduces the loads on the primary RDS instance.

Prerequisites

The dedicated proxy service is enabled for your database system. For more information, see Enable the dedicated proxy service for an ApsaraDB RDS for MySQL instance.

Background information

By default, the enabled dedicated proxy sends all the requests that are encapsulated in transactions to the primary RDS instance. This ensures the correctness of the transactions. However, in some frameworks, the autocommit mode is disabled by using the set autocommit=0; command. As a result, all requests are encapsulated in the transactions that are not automatically committed. This causes heavy loads on the primary RDS instance. In this case, you can enable the transaction splitting feature.

After the transaction splitting feature is enabled with the default isolation level READ COMMITTED, ApsaraDB RDS starts a transaction only for write operations. This applies if the autocommit mode is disabled. Read requests that arrive before the transaction is started are routed to the read-only RDS instances by using a load balancer.

Note
  • Explicit transactions cannot be split. These explicit transactions include the transactions that are started by using the BEGIN or START statement.
  • After the transaction splitting feature is enabled, global consistency cannot be ensured. Before you enable the transaction splitting feature, we recommend that you evaluate whether this feature is suitable for your workloads.
Transaction splitting architecture

Procedure

  1. Go to the Database Proxy page.
    1. Log on to the ApsaraDB for RDS console. In the left-side navigation pane, click Instances. In the top navigation bar, select the region where your RDS instance resides.
      选择地域
    2. Find your RDS instance and click its ID. In the left-side navigation pane, click Database Proxy.
  2. Click the Read/Write Splitting tab and click Enable to the right of the Transaction Splitting parameter.
    Note
    • If you no longer require the transaction splitting feature, you can click Disable to the right of the Transaction Splitting parameter to disable this feature.
    • After you enable or disable the transaction splitting feature, the new setting is applied only to new connections.

Related operations

API Description
DescribeDBProxy Queries details about the dedicated proxies of an ApsaraDB RDS instance.
DescribeDBProxyEndpoint Queries information about the dedicated proxy endpoints of an ApsaraDB RDS instance.
ModifyDBProxyEndpoint Modifies information about the dedicated proxy endpoints of an ApsaraDB RDS instance.