What are different load balancing algorithms? 

Here they are:

  • Round Robin
  • Weighted Round Robin
  • Least Connections
  • Fastest Response
  • IP Hash
  • URL hash

What is Round Robin algorithm? 

As per this algorithm, requests are distributed across the group of servers sequentially, looping through available servers in a fixed sequence.  This way the load is pretty evenly distributed across your servers in a simple-to-understand and predictable pattern.  

What is Weighted Round Robin? 

This algorithm is the same as round-robin but some servers get a bigger share of the overall workload based on some criteria.

 In the normal, standard round-robin, each server is given equal weight (let’s say all are given a weighting of 1).  But when you have different weight servers, then you can have some servers with a lower weighting (say 0.5, if they’re less powerful),  and others can be higher like 0.7 or 0.9 or even 1.

Then the total traffic will be split up in proportion to those weights and allocated accordingly to the servers that have power proportionate to the volume of requests.

What is least Connections algorithm? 

As per the least connection algorithm, a new request is sent to the server with the fewest current connections to clients. The relative computing capacity of each server is factored into determining which one has the least connections.

What is fastest Response algorithm? 

Fastest Response: The load balancer regularly pings the servers and mainatains a map of servers with least response times. Traffic is routed to the servers in clusters with least response times.

What is IP Hash based Load Balancing algorithm? 

In this case, the Hash function applied to the IP address of the client is used to determine which server receives the request.

You configure your load balancer to calculate the hash function on the IP address of incoming requests and use the hash value to determine which server to direct the request to.

 If I had 10 servers available, then the hash function would be designed to return one of 10 hash values, so one of the servers definitely gets nominated to process the request.

The hash function can be smarter so that requests from a certain country or region to get data from a server that is best suited to address the needs from within that region. It can also help to ensure that the request goes to a server that has previously cached the same request, as this will improve speed and performance in processing and responding to that request.

What is URL Hash algorithm? 

This algorithm is like an IP hash, except hashing is done on the URL of the request.

This algorithm have its own advantages, as requests for a given object will always go to specific server or servers. And if this server have cached that specific URL or object data, then request can be quickly served from cache. This avoids cache duplication, having the same object stored in several / all caches, and increases effective capacity of the backend caches.

Rakesh Kalra

Hello, I am Rakesh Kalra. I have more than 15 years of experience working on IT projects, where I have worked on varied complexity of projects and at different levels of roles. I have tried starting my own startups, 3 of those though none of it were successful but gained so much knowledge about business, customers, and the digital world. I love to travel, spend time with my family, and read self-development books.