This topic introduces the transaction splitting function provided by the database proxy of ApsaraDB for RDS. This function identifies and distributes read requests initiated before write requests within a transaction to read-only instances. This reduces workloads on the primary instance.

Prerequisites

The database proxy is enabled for the instance. For more information, see Dedicated proxy.

Background information

By default, the dedicated proxy sends all requests in a transaction to the primary instance to ensure correctness of the transaction. However, some frameworks encapsulate all requests to a transaction that is not automatically committed because autocommit is disabled (set autocommit=0;). This brings heavy workloads on the primary instance. In this case, you can enable the transaction splitting function.

When transaction splitting is enabled and the default isolation level READ COMMITTED is used, the RDS instance starts a transaction only for write requests when autocommit is disabled. Read requests that arrive before the transaction is started are distributed to read-only instances by the load balancer.

Note
  • Explicit transactions do not support splitting, such as transactions started by using the BEGIN or START statement.
  • After transaction splitting is enabled, global consistency cannot be ensured. If your business requires global consistency, we recommend that you evaluate whether you can enable transaction splitting.
Transaction splitting

Procedure

  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 the target RDS instance resides.
    Select a region
  3. Find the target instance and click the instance ID.
  4. In the left-side navigation pane, click Database Proxy.
  5. In the Proxy Endpoint section of the Proxy Service tab, click Enable on the right of Transaction Splitting:.
    Note
    • When you no longer need transaction splitting, you can click Disable on the right of Transaction Splitting:.
    • The operation to enable or disable transaction splitting takes effect only on new connections.