Transaction splitting

更新时间:
复制 MD 格式

The transaction splitting feature of the database proxy for ApsaraDB for MyBase for MySQL forwards read requests that occur in a transaction to read-only instances before any write operations are performed. This reduces the load on the primary instance.

Prerequisites

The database proxy service is enabled. For more information, see Enable and configure a database proxy.

Background information

By default, the ApsaraDB for MyBase database proxy sends all requests within a transaction to the primary instance to ensure transaction correctness. However, some frameworks encapsulate all requests in transactions and disable autocommit using set autocommit=0;. This can cause a high load on the primary instance. You can use the transaction splitting feature to reduce this load.

Transaction splitting is enabled by default. When you use the default Read Committed isolation level and autocommit is disabled, a transaction starts only when a write operation occurs. Read requests that occur before the transaction starts are routed to read-only instances by the load balancing module.

Note
  • Explicit transactions, such as those that start with `begin` or `start transaction`, cannot be split.
  • Some services require global consistency. Transaction splitting does not provide global consistency. Before you enable this feature, evaluate whether it is suitable for your services.
事务拆分

Enable or disable transaction splitting

  1. Log on to the ApsaraDB for MyBase console.
  2. In the upper-left corner of the page, select the destination region.
  3. In the navigation pane on the left, click Instance List.
  4. Find the primary instance that you want to manage and click Details in the Actions column.
  5. In the navigation pane on the left, click Database Proxy, and then click the Proxy Endpoint (formerly Read/Write Splitting) tab.
  6. To the right of Transaction Splitting, click Enable or Disable.
    Note Changes to the transaction splitting setting take effect only for new connections.

Related API operations

APIDescription
ModifyDBProxyEndpointAdds, modifies, or deletes a database proxy endpoint.