Updated on 2023-10-18 GMT+08:00

Load Balancing

Load balancing functions on the client and is an indispensable key component of a high-concurrency and high-availability system. It aims to evenly distribute network traffic to multiple servers to improve the overall response speed and availability of the system.

  • Load balancing of Java chassis is used for microservice consumers. The load balancing module must be integrated into microservice applications and the loadbalance processing chain must be enabled.
    Configuration example:
    servicecomb:
      handler:
        chain:
          Consumer:
            default: loadbalance
      loadbalance:   
        strategy:     
          name: RoundRobin #The polling mode is enabled.

    Add the following dependency to the POM file:

     <dependency>
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>handler-loadbalance</artifactId>
       <version>${project.version}</version>
    </dependency>
  • Spring Cloud Huawei load balancing is based on Ribbon in Spring Cloud and works on the client. The principles are as follows: When a random rule is used, the client randomly accesses an instance in the downstream microservice instance. When a polling rule is used, the client cyclically selects a server in the downstream microservice instance in sequence.

    Configuration example:

    servicecomb:
      loadbalance:
        userLoginAction: | 
          rule: Random #The random mode is enabled. The default mode is polling.