Updated on 2023-12-21 GMT+08:00

Introducing Read Weight Assignment Rules

Read weights are assigned to read replicas by their specifications.

Weight Assignment Rules

The system automatically assigns read weights to read replicas based on their specifications, as shown in the following table.

The default weight of a read replica is (Number of vCPUs) x 50.

If the number of vCPUs is 4, the weight is 200 (4 x 50 = 200).

Table 1 Weights assigned to read replicas

vCPUs

Memory (GB)

Weight

4

16

200

8

32

400

16

64

800

32

128

1,000

48

192

1,000

60

256

1,000

Specifying Whether a SQL Statement Is Sent to the Primary Node or Read Replica By Adding a Hint

Hints supported by read/write splitting are as follows:

/*FORCE_MASTER*/: A SQL statement is executed on a primary node.

/*FORCE_SLAVE*/: A SQL statement is executed on read replicas.

  • In addition to the weight assignment rules of read/write splitting, hints serve as a complementary SQL syntax to specify whether a SQL statement is executed on a primary node or read replica.
  • Hints are only used as routing suggestions. In non-read-only SQL and non-transaction scenarios, SQL statements cannot be routed to read replicas.
  • If you want to connect to an instance using the MySQL CLI and Hints, add the -c option.