Relational Database Service (MySQL)

Read/Write Separation

2024-06-21 08:32:07

DRDS uses the following two methods to enable the read/write separation function.

Configuring Balance Attributes

Go to the DRDS Console > Grouping Management > Default Grouping > Associate RDS Settings > Property Configuration. The read/write separation configuration parameters include the options Disable, Send Read Statements to the Read Library, and Send Read Statements to the Read Library or Write Library Randomly.

• Disable: Indicates that read/write separation is disabled, and all statements are sent to the write node.

• Send Read Statements to the Read Library: Indicates that the read/write separation is enabled. All SELECT statements outside the transaction (autocommit=1) are sent to the read node; all statements within the transaction (autocommit=0) are sent to the write node.

• Send Read Statements to the Read Library or Write Library Randomly: Indicates that the read/write separation is enabled. All SELECT statements outside the transaction (autocommit=1) are sent to the read node or write node randomly; all statements within the transaction (autocommit=0) are sent to the write node.

HINT Statements

By using the /* !HINT({"balance":"?”})*/, the SELECT statements are forced for read-and-write seperation according to the specified rules. The balance can be valued in three ways, similar to the balance attributes of DRDS:

• /* !HINT({"balance":"0”})*/ Force to send SELECT statements to the write node.

• /* !HINT({"balance":"1”})*/ Force to send SELECT statements to the read node.

• /* !HINT({"balance":"2"})*/ Force to send SELECT statements to the read node or write node randomly.


tbUjqa_NafS9