All Products
Search
Document Center

ApsaraDB RDS:Transaction splitting

Last Updated:Jan 08, 2024

If your primary ApsaraDB RDS for PostgreSQL instance is heavily loaded due to a large number of requests encapsulated in transactions that are not automatically committed, you can enable the database proxy feature for the primary RDS instance. This feature provides the transaction splitting capability to ensure read/write consistency and to forward the read requests prior to write operations in transactions to read-only RDS instances. This way, the loads on the primary RDS instance are reduced.

Prerequisites

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

Feature description

The database proxy feature of ApsaraDB RDS for PostgreSQL automatically sends all requests in a transaction to the primary RDS instance to ensure read/write consistency within the transaction. In some cases, all requests are encapsulated in transactions that are not automatically committed. As a result, the primary RDS instance is heavily loaded but the read-only RDS instances are lightly loaded.

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 you enable the database proxy feature, transaction splitting is automatically enabled. In this case, 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. You cannot disable transaction splitting.

  • Explicit transactions cannot be split. Explicit transactions include the transactions that are started by executing the BEGIN or START TRANSACTION 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.

Related operations

Operation

Description

DescribeDBProxy

Queries the details of a database proxy.

DescribeDBProxyEndpoint

Queries the information about a database proxy endpoint.