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 usingset 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
- Log on to the ApsaraDB for MyBase console.
- In the upper-left corner of the page, select the destination region.
- In the navigation pane on the left, click .
- Find the primary instance that you want to manage and click Details in the Actions column.
- In the navigation pane on the left, click Database Proxy, and then click the Proxy Endpoint (formerly Read/Write Splitting) tab.
- 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
| API | Description |
| ModifyDBProxyEndpoint | Adds, modifies, or deletes a database proxy endpoint. |
该文章对您有帮助吗?