Table of Contents

What are the different load balancing algorithms

What are the different load balancing algorithms ?

There are multiple different types of load balancing algorithms that a load balancer can use while routing requests from a client.

1 Round Robin

Round robin algorithm is the simplest of all the load balancing algorithms. In this algorithm, the requests are routed to a server in a sequentially.
For example, if you have three servers "A", "B" and "C". Then the first request which comes will be mapped to "A", second request will be mapped to "B", and third request will be mapped to "C". After that the 4th request will be again mapped to "A" and so on.

The main advantage of round robin algorithm are that it is easy to implement and is suitable for most small use cases and if all the servers have similar capacity.

2 Weighted Round Robin

In weighted round robin load balancing algorithm, we assign weights to the server (depending on the amount of load a server can handle). This makes sure that the server with higher weight gets the most amount of requests. Unlike in round robin algorithm, where the ratio of requests that get processed by each server is equal, in weighted round robin algorithm the amount of requests that get processed by each server is in direct proportion to it’s weight.

Weighted round robin is useful, if the servers have different capacity and few of the servers are able to handle more load compared to other servers.

3 Random

In random load balancing algorithm, the requests are distributed randomly.

4 Least Connections

In least connections load balancing algorithm, the load balancer keeps a count on the number of open connections for each server. Whenever a request comes, the load balancer will route that request to a server which has least number of connections open.

5 Least Traffic

In the least traffic load balancing algorithm, the load balancer monitors the outgoing traffic rate for each of the servers. Whenever, a request comes to the load balancer, it routes that request to the server which is serving least amount of traffic currently.

6 IP Hash

In this load balancing method, the load balancer will calculate the hash value of the source IP address and map it to a particular server. For example, if the source IP of a request is 45.114.49.25 and it gets mapped to server "A", the request will be routed to server "A". This makes sure that any request which originates from IP 45.114.49.25 is always processed by server "A".

7 URL Hash

This method is similar to IP Hash Load balancing that we saw above. Instead of calculating the hash of the IP address as shown above, we calculate the hash of the URL of the request. For example, when handling a request such as "https://prepfortech.in/load-balancing", we will calculate the hash of the value "/load-balancing" and map it to an application server (let’s say it gets mapped to "B"). Then all the future requests for this url will be served by application server "B"

Scroll to Top