Updated on 2026-11-03 GMT+08:00

Changing the Routing Policy of a Proxy Instance

Scenarios

You can configure the routing policy when creating a proxy instance. The default routing policy is weighted. You can also change the routing policy of an existing instance.

Working Principles of the Routing Policy

TaurusDB proxy instances support weighted, load balancing (database nodes or proxy nodes), and nearby AZ routing policies. You can configure the policy as needed.

Read requests are assigned to nodes based on the weights you specify.

As shown in the figure, when the proxy instance uses weighted routing and selects the primary node and read replicas R1 and R2 with a read weight ratio of 0:1:2, application A's write requests are automatically forwarded to the primary node while read requests are routed to read replicas R1 and R2 at a 1:2 ratio.

Figure 1 Weighted routing

Read requests are distributed based on the number of active connections. Read requests are routed to nodes with fewer active connections. No weight configuration is required for this policy.

Depending on the source of load data, the load balancing routing policy has two modes:

  • Load balancing (database nodes): Active connection counts are obtained from database nodes and used as the basis for request distribution.
    • Application scenarios
      • Multiple proxy instances connected to the same group of database nodes: The number of active connections is a global metric, so all proxy instances see the same load status. This prevents multiple proxy instances from routing requests to the same node simultaneously.
      • The overall load on backend database nodes needs to be monitored.
      • Real-time routing decisions are not a priority.
    • How it works

      The database proxy instance periodically queries the number of active connections on each database node. When a read request arrives, the proxy instance routes it to the node with the fewest active connections. If multiple nodes have the same number of active connections, one is selected at random.

      As shown in the following figure, the proxy instance uses the load balancing (database nodes) routing mode, with the primary node and read replicas R1 and R2 selected. The proxy instance determines which node to forward read requests to based on the number of active connections on each node.

      When read replica R2 has a high number of active connections and is under heavy load, the proxy instance forwards most read requests to read replica R1 and the primary node, which have lower loads, to reduce pressure on R2.

      Figure 2 Load balancing (database nodes)
  • Load balancing (proxy nodes): The proxy instance locally tracks the number of active connections and distributes requests based on the connection counts updated in real time.
    • Application scenarios
      • Real-time routing decisions are critical: Connection counts are updated in real time without delay.
      • Nodes overloaded by slow SQL queries need to be accurately identified: Connections remain counted as active while they are occupied by slow SQL query. This allows the proxy instance to accurately identify heavily loaded nodes and avoid routing requests to them.
      • Backend resource overhead needs to be reduced: The proxy instance does not need to periodically query database node status, reducing backend connection resource consumption.
    • How it works

      The proxy instance locally tracks the number of active connections from itself to each database node in real time. When a read request arrives at the current proxy node, the proxy node routes it to the database node with the fewest active connections.

      Unlike the load balancing (database nodes) routing policy, the load balancing (proxy nodes) policy does not require queries to database nodes. All load data is maintained locally by each proxy instance in real time.

      As shown in the following figure, each proxy node independently tracks the number of active connections from itself to each database node. For example, R1 = 3 indicates that the proxy node has three active connections to read replica R1. Each proxy node routes read requests to the database node with the fewest active connections. Because the requests received by each proxy node differ in source and timing, the connection counts on different proxy nodes may vary at the same time. However, each proxy node independently routes requests to the node with the fewest active connections. Overall, the number of active connections across database nodes tends to become balanced. In the following figure, both R1 and R2 have six active connections.

      Figure 3 Load balancing (proxy nodes)
Table 1 Comparison of the two load balancing modes

Dimension

Load Balancing (Database Nodes)

Load Balancing (Proxy Nodes)

Data source

Active connection counts on database nodes

Used connection counts maintained locally by the proxy instance

Update delay

Periodic queries, with delay

Real-time updates, without delay

Metric scope

Global (all clients)

Current proxy instance only

Backend overhead

Requiring periodic queries to database nodes

No backend query overhead

Slow SQL detection

Possibly inaccurate (The number of active connections may remain low during lock waits.)

Accurate (Connections executing slow SQL statements remain counted as active.)

Node recovery detection

Detected only after the next periodic query

Detected immediately when connections are released

Multiple proxy instances

All proxy instances have a consistent view of the global load, allowing them to make coordinated routing decisions.

Each proxy instance sees only its local load, so load information may differ across proxy nodes.

A proxy node preferentially routes read requests to the database nodes located in the same AZ as the proxy node. In this policy, you are advised to deploy the proxy instance and the TaurusDB nodes in the same AZ to reduce the distribution latency.

As shown in the figure, the proxy instance contains two nodes located in different AZs (AZ 1 and AZ 2). Write requests are routed to the primary node (M) and read requests are routed to the nearest nodes based on the AZ of the application (M and R1 in AZ 1; R2 and R3 in AZ 2) to reduce network latency and improve performance. When all proxy nodes are in AZs different from all TaurusDB instance nodes, the routing policy switches to load-balancing mode.
Figure 4 Nearby AZ routing

Precautions

  • Proxy instances running database proxy kernel version 2.22.07.000 or later support the load balancing (database nodes) mode. If your proxy instance does not meet this requirement, upgrade it to the latest version by referring to Upgrading the Kernel Version of a Proxy Instance.
  • Proxy instances running kernel version 2.26.09.000 or later support the load balancing (proxy nodes) mode. If your proxy instance does not meet this minor kernel version requirement, upgrade it to the latest version by referring to Upgrading the Kernel Version of a Proxy Instance.
  • Proxy instances running kernel version 2.23.12.000 or later support the nearby AZ routing mode. If your proxy instance does not meet this minor kernel version requirement, upgrade it to the latest version by referring to Upgrading the Kernel Version of a Proxy Instance.

For details about how to check the kernel version, see How Can I Check the Version of a TaurusDB Instance?

Procedure

  1. Log in to the TaurusDB console.
  2. Click in the upper left corner and select a region.
  3. On the Instances page, click the instance name.
  4. In the navigation pane, choose Database Proxy.
  5. Click the name of a proxy instance.
  6. On the Basic Information page, click Configure under Routing Policy.
  7. In the displayed dialog box, configure required parameters.

    Figure 5 Changing the routing policy of a proxy instance

    Table 2 Parameter description

    Parameter

    Description

    Routing Policy

    • Weighted: Read requests are assigned to nodes based on the weights you specify.
    • Load balancing (database nodes): Read requests are distributed based on the number of active connections on each database node. Read requests are routed to nodes with fewer active connections. No weight configuration is required for this policy.
    • Load balancing (proxy nodes): The proxy instance independently tracks the number of active connections from itself to each database node and prioritizes routing read requests to the node with the fewest active connections.
    • Nearby AZ: A proxy node preferentially routes read requests to the database nodes located in the same AZ as the proxy node.

    Associate New Nodes

    After this function is enabled, new read replicas will be automatically associated with the current proxy instance.

    If Routing Policy is Weighted, you need to configure read weights for the new nodes. The default weight of a node is 100. Nodes with higher weights process more read requests.

    Database Nodes

    The proxy mode of a proxy instance determines which nodes read requests are assigned to.

    • Read-only mode: All read requests are assigned to the selected read replicas, but not to the primary node.
    • Read/write mode: All read requests are assigned to the selected nodes (including the primary node and read replicas) based on the routing policy.

  8. Click OK. The proxy instance status changes to Configure routing policy.
  9. After several minutes, check that the proxy instance status becomes Available and the routing policy is updated.