Load Balancers and the fundamental Algorithms it uses.

Ian Kiprono
2 min readOct 4, 2023

--

Gif showing both Static and Dynamic Algorithms used by Load Balancers

Load balancers play a crucial role in large, robust, and scalable systems, especially in distributed environments. They can handle millions of incoming requests, distribute traffic between servers and generally keep things smooth with minimal configuration.

To achieve this, Load balancers uses a couple of Algorithms. Below are some of the Algorithms.

  1. Static Algorithms.

Round robin- The requests are distributed sequentially among a group of servers. It offers no guarantee that multiple requests from a user can reach the same instance.

Sticky Round Robin- This serves as a better alternative to the Round Robin Algorithm. Different requests from the same user go to the same instance.

Hash-Based- This algorithm distributes requests based on the hash key value. The key can be IP address or the URL of the request.

Weighted Round Robin- In this algorithm, each server gets a weight value. This value determines the proportion of the Traffic. Servers with higher weight receive more traffic. This is best suited for setups having servers at different capacity levels.

2. Dynamic Algorithms.

Least Connections- In this algorithm, new requests are sent to the servers with the least number of connections. The number of connections is determined based on the relative compute capacity of a server.

Least Response Time- In this algorithm, a new request is sent to the server with the lowest response time in order to minimize the overall response time. It is good for cases where response time is critical.

That is it. Thank you for your time.

Credits to @ProgressiveCod2 on twitter.

--

--

Ian Kiprono

Java Software Engineer and a Problem solver. Putting my random thoughts out there. The world is beautiful and I am on a mission to make it better.