DevOps Practice

Load Balancing: Round Robin May Not Be the Right Choice

Based on our experience, we believe Round Robin may not be an effective load balancing algorithm, because it doesn’t equally distribute traffic among all nodes. You might wonder, how is this possible?

How Does Round Robin Algorithm Work?

Round Robin algorithm sends requests among nodes in the order that requests are received. Here is a simple example.

Let’s say you have three nodes: node-A, node-B and node-C.

  • First request is sent to node-A.
  • Second request is sent to node-B.
  • Third request is sent to node-C.

The load balancer continues sending requests to servers based on this order. It makes it sound like traffic would get equally distributed among the nodes. But that isn’t true.

What is the Problem with Round Robin Algorithm?

Figure 1: Load Balancer with 2 nodes (Round Robin).

Let’s pick up a simple example: Let’s say you launched your web application with a load balancer and it has two nodes (node-A, node-B) behind it. The load balancer is configured to run with Round Robin algorithm, and sticky-session load balancing is enabled. Let’s say 200 users are using your application currently. Since the Round Robin algorithm is enabled in load balancer, each node will get 100 users requests.

Figure 2: New node added. Newly added node gets less traffic in Round Robin algorithm.

A few minutes later, you are adding node-C. Now, an additional 100 users start using the application. Since it’s Round Robin algorithm, load balancer will distribute new users’ requests equally to all 3 nodes (i.e., 33 users request to each node). But remember node-A and node-B is already processing 100 users requests each. So now node-A and node-B will end up processing 133 users requests each (i.e., 100 original users requests, plus 33 new users requests), whereas node-C will process only 33 (new) users requests. Now, do you see why Round Robin isn’t equally distributing the traffic?

In the Round Robin algorithm, the older nodes in the pool will always end-up processing more requests while newly added nodes will end up processing less amount of traffic. The load is never evenly distributed. For maintenance, patching and installation purposes, you have to continually keep adding and removing nodes from the load balancer pool. If you instrumented auto-scaling in place it gets worse, because in auto-scaling nodes are more dynamic. They get added and removed even more frequently.

What Algorithm to Use?

Figure 3: New node added. Traffic is evenly distributed in Least Connections.

There are a variety of load balancing algorithms: Weighted Round Robin, Random, Source IP, URL, Least Connections, Least Traffic, Least Latency. Given the shortcoming in Round Robin, you can consider trying other choices. One choice you may consider is: Least Connections algorithm. As per this algorithm, the node which has the least number of connections will get the next request. So, as per our earlier example, when 100 new users start to use the application, all new user requests will be sent to node-C. Thus, load will be equally distributed among all nodes.

Surya Baby

Surya Baby

Surya Baby is digital marketing executive at Vmoksha Technologies.

Recent Posts

Survey Sees AI Playing Larger Role in Test Automation

A Tricentis survey found organizations could see massive costs savings by fully automating mobile application testing.

1 hour ago

A Brief History of DevOps and the Link to Cloud Development Environments

The history of DevOps is worth reading about, and “The Phoenix Project,” self-characterized as “a novel of IT and DevOps,”…

1 hour ago

The Rise of Low-Code/No-Code in DevOps

The rise of low-code/no-code platforms in DevOps is reshaping the way software is developed and deployed.

2 hours ago

Building an Open Source Observability Platform

By investing in open source frameworks and LGTM tools, SRE teams can effectively monitor their apps and gain insights into…

1 day ago

To Devin or Not to Devin?

Cognition Labs' Devin is creating a lot of buzz in the industry, but John Willis urges organizations to proceed with…

1 day ago

Survey Surfaces Substantial Platform Engineering Gains

While most app developers work for organizations that have platform teams, there isn't much consistency regarding where that team reports.

2 days ago