Help Center> Elastic Load Balance> User Guide> Listener> Load Balancing Algorithms

Load Balancing Algorithms

Shared and dedicated load balancers support the following load balancing algorithms:

  • Weighted round robin: Requests are distributed across backend servers in sequence based on their weights. Backend servers with higher weights receive proportionately more requests, whereas equal-weighted servers receive the same number of requests. This algorithm is typically used for short connections, such as HTTP connections.
  • Weighted least connections: In addition to the number of active connections to each backend server, a weight is assigned to each backend server based on their processing capability. This algorithm is typically used for persistent connections, such as database connections.
  • Source IP hash: The source IP address of each request is calculated using the consistent hashing algorithm to obtain a unique hash key, and all backend servers are numbered. The generated key allocates the client to a particular server. This allows requests from different clients to be routed based on source IP addresses and ensures that a client is directed to the same server that it was using previously. This algorithm is typically used for TCP connections of load balancers that do not use cookies.
  • Connection ID: The connection ID in the packet is calculated using the consistent hash algorithm to obtain a specific value, and backend servers are numbered. The generated value determines to which backend server the requests are routed. This enables requests with different connection IDs to be routed and ensures that requests with the same connection ID are routed to the same backend server. This algorithm applies to requests to applications that use QUIC as the protocol.

    Currently, only dedicated load balancers support the Connection ID algorithm.

    The following figure shows an example of how requests are distributed using the connection ID algorithm. Two backend servers are in the same AZ and have the same weight. If backend server 01 has processed a request from client A, the load balancer will route new requests from client A to backend server 01.

    Figure 1 Traffic distribution using the connection ID algorithm
Classic load balancers support the following load balancing algorithms:
  • Round robin: Requests are distributed sequentially across all servers, so that the load is evenly shared. This algorithm is typically used for short connections, such as HTTP connections.
  • Least connections: a dynamic scheduling algorithm that estimates backend server load based on the number of active connections. Requests are routed to servers with the minimum number of connections. This algorithm is typically used for persistent connections, such as database connections.
  • Source IP hash: The source IP address of each request is calculated using the consistent hashing algorithm to obtain a unique hash key, and all backend servers are numbered. The generated key allocates the client to a particular server. This allows requests from different clients to be routed based on source IP addresses and ensures that a client is directed to the same server that it was using previously. This algorithm is typically used for TCP connections of load balancers that do not use cookies.

To select a load balancing algorithm, perform the following steps:

  1. Log in to the management console.
  2. In the upper left corner of the page, click and select the desired region and project.
  3. Click Service List. Under Network, click Elastic Load Balance.
  4. Locate the load balancer and click its name.
  5. Click Backend Server Groups and click on the right of the backend server group name.
  6. Select a load balancing algorithm.

    The modification takes effect immediately and affects only request routing over new connections.

  7. Click OK.