To use ELB, you must create a load balancer first. The load balancer receives requests from clients and routes the requests to backend servers in one or more AZs. The load balancing algorithm determines how the traffic is distributed.
Classic load balancers provide the following load balancing algorithms:
- Round robin: New connection requests are distributed sequentially across all ECSs, so that request workload is evenly shared.
- Least connections: New connection requests are forwarded to the ECS processing the least number of connections at that time.
- Source IP hash: The source IP address of the request is input into a hash algorithm, and the resulting hash is used to identify an ECS in the static fragment table.
Enhanced load balancers support the following load balancing algorithms:
- Weighted round robin: Connection requests are forwarded to different servers based on their weights, which indicate server processing performance. Backend servers with higher weights receive proportionately more requests, whereas equal-weighted servers receive the same number of requests.
- Weighted least connections: In addition to the weight assigned to each server, the number of connections processed by each backend server is also considered. Connection requests are forwarded to the server with the lowest connections-to-weight ratio.
- Source IP hash: The source IP address of the request is input into a hash algorithm, and the resulting hash is used to identify a server in the static fragment table.
The following figure shows how traffic is distributed using the weighted round robin algorithm. Four backend servers have the same weight, and each server receives the same proportion of requests.
Figure 1 Traffic distribution using the weighted round robin algorithm