doc-exports/docs/gaussdb_mysql/umn/gaussdb_02_0011.html
Ru, Li Yi f3715d9cc9 gaussdbmysql
Reviewed-by: Wagner, Fabian <fabian.wagner@t-systems.com>
Co-authored-by: Ru, Li Yi <liyiru7@huawei.com>
Co-committed-by: Ru, Li Yi <liyiru7@huawei.com>
2024-09-06 12:45:25 +00:00

4.7 KiB

Introducing Read/Write Splitting

Read/write splitting enables read and write requests to be automatically routed through a proxy address. You can create a proxy instance by referring to Creating a Proxy Instance after read replicas are created. Thanks to the IP address of the proxy instance, write requests are automatically routed to the primary node and read requests are routed to read replicas and the primary node by user-defined weights.

Constraints

  • Read/write splitting can be enabled only when at least one read replica is created.
  • After read/write splitting is enabled, the database port, private IP address, and security group cannot be changed.
  • Proxy does not support READ-UNCOMMITTED transaction isolation.
  • A maximum of four proxy instances can be created for a GaussDB(for MySQL) instance.
  • To use database proxy instances, ensure that the data in a single row of a table cannot exceed 16 MB.
  • After read/write splitting is enabled, both the database port and the security group of the primary node and read replicas are changed.
  • Read/write splitting does not support SSL encryption.
  • Read/write splitting does not support the compression protocol.
  • If multi-statements are executed, all subsequent requests will be routed to the primary node. To restore the read/write splitting function, you need to disconnect the connection between applications and the read/write splitting address and establish a connection again.
  • The port number of a proxy instance is independent of that of a DB instance. Changing the port number of the DB instance does not change that of the proxy instance. The default port number of a proxy instance is 3306.

Scenarios

When enabling read/write splitting for an instance, you need to select the nodes (including the primary node and read replicas) to be associated to the proxy instances.

  • Different applications can connect to the instance through the IP addresses of different proxy instances. Read requests are routed to the proxy instances that applications connect to. You can also add nodes to or remove nodes from proxy instances.
  • A primary node or read replica can be added to multiple proxy instances at the same time, and then is assigned different read weights. For details about how to assign weights, Assigning Read Weights.
  • In the read/write mode, all write requests are routed to the primary node, and read requests are routed to each node based on the read weights.
  • In the read-only mode, only read requests can be routed to read replicas based on the read weights. Even if the primary node is assigned with a read weight, the weight does not take effect.
Figure 1 Multiple proxy instances