The TencentDB for MySQL database proxy provides an adaptive load balancing feature that routes requests to less loaded instances based on backend load conditions. This achieves load balancing across database instances to ensure the response speed of database instances.
Background Information
The TencentDB for MySQL database proxy provides load balancing capabilities when multiple read-only instances are used in database scenarios. It distributes requests across read-only instances to reduce the load pressure on the primary instance. Currently, the TencentDB for MySQL database proxy supports "static" load balancing by assigning read weights to each read-only instance. This ensures that read requests are distributed according to the configured read weights.
If different services access the instance simultaneously through different database proxy connection addresses, load imbalance may occur. This phenomenon may not be resolved by the "static" load balancing capability.
For example, a user has one primary instance and two read-only instances (RO1, RO2), where RO2 is used by two database proxy connection addresses. When the load on RO2 increases, due to this "static" load balancing capability, the number of requests allocated to it remains fixed. Thus, even if RO2's response slows down, it continues to receive requests, which slows down the overall response speed. Therefore, the TencentDB for MySQL database proxy provides an adaptive load balancing feature. When it detects that requests to RO2 are slowing down and the load is too high, the database proxy reduces the requests allocated to RO2 and redirects them to other read-only instances, thereby achieving "dynamic" load balancing and ensuring the overall response speed of the database instances.
Prerequisites
The instance status is running, and the instance has a two-node or three-node architecture.
The MySQL 5.7 kernel minor version must be 20211030 or later.
The MySQL 8.0 kernel minor version must be 20211202 or later.
Scenarios
If the overall load of your instance is high, and one read-only instance becomes fully loaded while others are not, enabling the adaptive load balancing proxy will prioritize routing requests to instances that can still respond. This maximizes resource utilization across all instances. Note that if an instance becomes fully loaded due to unreasonable slow SQL, adaptive load balancing may cause high load on all instances. In such cases, the slow SQL issue still needs to be resolved.
If all your instances have identical specifications and are configured with the same weight, you can directly enable adaptive load balancing when traffic needs to be evenly distributed. This solution can adapt to the requirements of almost all scenarios.
In the following cases, it is not recommended to enable the adaptive load balancing feature:
1. If there is only one database proxy connection address, it is recommended to use the "static" load balancing capability, and it is not recommended to enable the adaptive load balancing feature.
2. After the adaptive load balancing feature is enabled, requests may not follow the configured read weights under low-load conditions. If you require strict adherence to the configured read weights, it is not recommended to enable the adaptive load balancing feature.
3. For cases where slow SQL causes a single read-only instance to become fully loaded, load balancing cannot alleviate the issue. In this scenario, it is not recommended to enable the adaptive load balancing feature. Instead, it is recommended to prioritize resolving the problem by optimizing SQL or scaling up instance specifications.
Precautions
Changing the load balancing policy only takes effect for new connections after the configuration change. If there are existing connections, the Rebalance operation may need to be performed to apply the changes to old connections. "Dynamic" load balancing only takes effect for traffic passing through the database proxy. If there is traffic that directly connects to the database without going through the proxy, it may cause instability in the load balancing policy.
Enable/Disable Adaptive Load Balancing
Note:
If network forwarding (only supported for Cluster Edition instances) is enabled in the configuration adjustment window, the adaptive load balancing feature is not supported.
The following steps are only for enabling/disabling adaptive load balancing. For detailed settings and descriptions under configuration adjustment, including the rules and impact of adjusting read weights, see Configure Database Proxy Connection Address. 1. Log in to the TencentDB for MySQL console, select a region at the top, and then click the target instance ID to go to the instance management page. 2. On the instance management page, choose Database Proxy > Overview, locate the target access address under Connection Address, and click Adjust Configurations in its Operation column.
3. On the adjustment configuration page, enable or disable the Adaptive Load Balancing toggle as needed, then click OK.