tencent cloud

Feedback

Adaptive Load Balancing

Last updated: 2024-08-30 13:06:59
    The TencentDB for MySQL database proxy provides the adaptive load balancing feature, which can route requests to instances with lower loads based on backend load conditions to achieve load balancing of database instances, ensuring the response speed of database instances.

    Background

    In database usage scenarios, when multiple read-only instances are used, a database proxy is usually required for load balancing, allowing multiple read-only instances to share the request load, thereby reducing the load on the primary instance. The current TencentDB for MySQL database proxy supports load balancing by assigning read weights to each read-only instance. This is a "static" load balancing capability, ensuring that requests are distributed to the read-only instances based on the set read weights.
    If different services access the instance simultaneously from different database proxy connection addresses, it might lead to load imbalance, which may not be solved by the "static" load balancing capability.
    For example, a user has 1 primary instance and 2 read-only instances (RO1 and RO2), where RO2 is used by two database proxy connection addresses. When the load on RO2 increases, the "static" load balancing capability results in a fixed number of requests being assigned to it. Therefore, even if RO2's response slows down, it will continue to be allocated requests, potentially slowing down the overall response. Consequently, the TencentDB for MySQL database proxy provides an adaptive load balancing feature. When it is found that the request of RO2 slows down and the load is too high, the database proxy will reduce the requests assigned to RO2 and assign them to other read-only instances, thus achieving a "dynamic" load balancing and ensuring the overall response speed of the database instances.
    

    Prerequisites

    The instance is running on the two-node or three-node architecture.
    The kernel minor version of the database proxy is 1.3.8 or later. If this requirement is not met, see Upgrading Kernel Minor Version of Database Proxy.
    Database kernel version requirements are as follows. If they are not met, see Upgrading Kernel Minor Version of Database.
    The MySQL 5.7 kernel minor version should be 20211030 or later.
    The MySQL 8.0 kernel minor version should be 20211202 or later.

    Overview

    If your instance has a high overall load and a certain read-only instance is fully utilized while others are not, enabling the adaptive load balancing proxy will prioritize sending requests to instances that can still respond, making full use of all instances' resources. Note that if the instance is fully utilized due to unreasonable slow SQL, the adaptive load balancing may result in high loads on all instances, and the slow SQL issue will still need to be addressed.
    If all your instances have the same specifications and all instances have the same configured weights, and you need to evenly distribute the traffic, you can directly enable the adaptive load balancing, which can meet almost all scenarios' requirements.
    In the following situations, 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 instead of enabling the adaptive load balancing feature.
    2. After the adaptive load balancing feature is enabled, and under low load conditions, requests may not be routed based on the set read weights. If you want to route requests in strict accordance with the set read weights, it is not recommended to enable the adaptive load balancing feature.
    3. For situations where slow SQL causes a single read-only instance to be fully utilized, load balancing cannot alleviate the issue. In this case, it is recommended to optimize the SQL or increase the instance specifications instead of enabling the adaptive load balancing feature.

    Precautions

    Changes to load balancing policies only take effect for new connections after the configuration is changed. If there are existing connections, you may need to perform the Load Rebalancing operation to make them take effect for the old connections.
    "Dynamic" load balancing can only take effect on traffic that goes through the database proxy. If there is traffic that directly connects to the database without going through the database proxy, the load balancing policy effect may be unstable.

    Enabling/disabling Adaptive Load Balancing

    Note:
    The following steps are only for enabling/disabling the adaptive load balancing. For detailed information about the specific settings and instructions under the adjusting configurations, including the rules and impacts of adjusting the read weights, see Modifying Access Policy.
    1. Log in to the MySQL Console, select a region at the top, and then click the ID of the target instance to enter the instance management page.
    2. On the instance management page, select Database Proxy > Overview, find the target access address under the Connection Address and click Adjust Configurations in the Operation column.
    
    3. On the Adjust Configurations page, click the button after Adaptive Load Balancing to enable or disable it, and then click OK.
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support