Load Balancing Algorithms
Overview
Load balancers receive requests from clients and forward them to backend servers in one or more AZs. Each load balancer has at least a listener and a backend server. The load balancing algorithm you select when you create the backend server group determines how requests are distributed.
Shared load balancers support the following load balancing algorithms: weighted round robin, weighted least connections, and source IP hash.
You can select the load balancing algorithm that best suits your needs.
Load Balancing Algorithm |
Description |
---|---|
Weighted round robin |
Routes requests to backend servers in sequence based on their weights. |
Weighted least connections |
Routes requests to backend servers with the smallest connections-to-weight ratio. |
Consistent hashing: Source IP hash |
Consistent hashing: Calculates the request fields using the consistent hashing algorithm to obtain a hash value and routes requests with the same hash value to the same backend server, even if the number of backend servers in the backend server group changes. Source IP hash: Calculates the source IP address of each request and routes requests from the same source IP address to the same backend server. |
How Load Balancing Algorithms Work
Shared load balancers support weighted round robin, weighted least connections, and source IP hash algorithms.
Figure 1 shows an example of how requests are distributed using the weighted round robin algorithm. Two backend servers are in the same AZ and have the same weight, and each server receives the same proportion of requests.
Description |
Requests are routed to 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. |
---|---|
When to Use |
This algorithm is typically used for short connections, such as HTTP connections.
|
Disadvantages |
|
Figure 2 shows an example of how requests are distributed using the weighted least connections algorithm. Two backend servers are in the same AZ and have the same weight, 100 connections have been established with backend server 01, and 50 connections have been established with backend server 02. New requests are preferentially routed to backend server 02.
Description |
In addition to the number of active connections established with each backend server, each server is assigned a weight based on their processing capability. Requests are routed to the server with the lowest connections-to-weight ratio. |
---|---|
When to Use |
This algorithm is often used for persistent connections, such as connections to a database.
|
Disadvantages |
|
Figure 3 shows an example of how requests are distributed using the source IP hash algorithm. Two backend servers are in the same AZ and have the same weight. If backend server 01 has processed a request from IP address A, the load balancer will route new requests from IP address A to backend server 01.
Description |
The source IP hash algorithm calculates the source IP address of each request and routes requests from the same IP address to the same backend server. |
---|---|
When to Use |
This algorithm is often used for applications that need to maintain user sessions or state.
|
Disadvantages |
|
Changing a Load Balancing Algorithm
- Go to the backend server group list page.
- On the Backend Server Groups page, locate the target backend server group and click Edit in the Operation column.
- In the Modify Backend Server Group dialog box, change the load balancing algorithm.
- Click OK.
The change is applied immediately and will be used to route requests over new connections. However, the previous load balancing algorithm will still be used to route requests over established connections.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot