What is the round-robin load balancing technique?

Overview

The purpose of load balancers is to improve the performance of applications and decrease the burden by "efficiently"Efficiency depends on server selection. distributing the incoming traffic across a group of servers. For user-facing applications, such as web search and web browsing, this will result in improved response times.

Note: Here, we will mainly talk about application load balancers.

Now, let’s jump right into the details of the round-robin load balancing technique.

About the technique

The round-robin load balancing technique is the simplest way to distribute traffic across a group of servers. The load balancer forwards the incoming requests to dedicated servers sequentially (one by one mechanism).

Note: Round-robin is a static load balancer, because it does not modify the state of the servers while distributing incoming traffic.

Example

Let’s understand this with the help of an example:

Suppose we have three servers —ServerA, ServerB, and ServerC— waiting to serve incoming requests behind the load balancer.

The load balancer will forward the first incoming request to ServerA, the second to ServerB, and the third to ServerC. When the fourth request arrives, the load balancer will forward this request back to ServerA. Similarly, the fifth and sixth requests will be forwarded to ServerB and ServerC respectively, and the cycle will continue on like this.

This cycle can be seen in motion in the illustration below:

Round-robin load balancing technique

Algorithmic explanation

  • i: This is the request number that is processed. It is initially set to zero.
  • T: This is the total number of servers that are available.

Algorithm

  1. Begin
  2. Assign the current request to the i mod Tth server.
  3. Increment variable i value by 1.
  4. Repeat steps 2 and 3 until there are no more requests.
  5. End.

Advantages

  • This algorithm is easy to understand and implement.
  • It utilizes fewer resources.
  • The request assignment is deterministic, and it is easy to determine the assigned server.

Limitations

This load balancing algorithm is not adaptive, as it does not consider the existing load on servers to distribute incoming requests. For example, even when a server (say, ServerA) is already processing a large request, the load balancer will still forward the next request to ServerA if it is its turn. At the same time, the other servers may be idle, having already completed their assigned tasks. Ideally, the load balancer should forward the request to the server whose current state is idle, but it does not do this.

Real time load balancers

  • Round robin load balancing is the default technique that is used in Nginx.

  • LVS

Copyright ©2024 Educative, Inc. All rights reserved