Updated on 2024-09-24 GMT+08:00

Changing Read Weights of Nodes

After a proxy instance is created, you can modify the read weights of its associated nodes. Read requests are forwarded to each node based on the read weights you specify, enabling read/write splitting and reducing the load of the primary node.

Constraints

  • The routing policy of proxy instances must be weighted.
  • You can configure read weights for both the primary node and read replicas.
  • The default read weight of the primary node is 0. The higher read weight the primary node is assigned, the more read requests it can process.
  • When the read weights of all nodes are 0, services are not affected. In this case, the primary node processes all read and write requests by default.
  • The weight of a read replica ranges from 0 to 1000.
  • If Associate New Node is enabled, new read replicas will be automatically associated to the current proxy instance. The default read weight of any new node is 100.
  • After a read replica is deleted, its weight is automatically removed while the weights of other read replicas remain unchanged.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner of the page, choose Databases > GaussDB(for MySQL).
  4. On the Instances page, click the instance name to go to the Basic Information page.
  5. In the navigation pane on the left, choose Database Proxy and click the name of a proxy instance to go to the Basic Information page.
  6. On the Basic Information page, click Configure next to Routing Policy.
  7. In the displayed box, configure Database Nodes.

    1. In the Available Nodes area on the left, select the nodes that you want associate to the current proxy instance or deselect the nodes that you want remove from the current proxy instance.
    2. In the Read Weight column of the Selected Nodes area on the right, configure read weights for nodes.
      Figure 1 Configuring read weights

    Example:

    As shown in Figure 2, one GaussDB(for MySQL) instance has one primary node and three read replicas. Two database proxy instances have been created and they both use the weighted routing policy.

    • The database proxy instance 1 is in the read/write mode. The primary node and read replica 1 are associated to the proxy instance 1 and assigned with a read weight of 100 and 200, respectively. They process read requests in the ratio of 1:2, that is, the primary node processes 1/3 read requests and read replica 1 processes 2/3 read requests. Write requests are automatically routed to the primary node.
    • The database proxy instance 2 is in read-only mode. Read replica 2 and read replica 3 are associated to the proxy instance 2 and assigned with a read weight of 100 and 200, respectively. Read replica 2 and read replica 3 process read requests in the ratio of 1:2. That is, read replica 2 processes 1/3 read requests, and read replica 3 processes 2/3 read requests.
    Figure 2 Read/Write splitting in multi-proxy scenarios (weighted routing policy)