Java, NoSQL, SQL, REST API and other scary words

Load Balancing for Dummies

The long story short – sometimes your application on a server got too many requests and you make a decision to add a brand new server. The question is – how to balance the load between these 2 servers?

Cause we are talking about about theoretical and simple things only – there are 3 basic methods:

  1. Round Robin
  2. Least Connect
  3. Weighted Least Connections

Round Robin is one of the simplest methods for distributing client requests across a group of servers. Going down the list of servers in the group, the round-robin load balancer forwards a client request to each server in turn. When it reaches the end of the list, the load balancer loops back and goes down the list again (sends the next request to the first listed server, the one after that to the second server, and so on).

There are 2 enhancements for this method:

  • Weighted round robin – A weight is assigned to each server based on criteria chosen by the site administrator; the most commonly used criterion is the server’s traffic-handling capacity. The higher the weight, the larger the proportion of client requests the server receives. If, for example, server A is assigned a weight of 3 and server B a weight of 1, the load balancer forwards 3 requests to server A for each 1 it sends to server B.
  • Dynamic round robin – A weight is assigned to each server dynamically, based on real-time data about the server’s current load and idle capacity.

*The most popular load balancer I ever heard is NGINX

Least Connect is the method that takes into account the current number of open connections between the load balancer and the server, and sends the traffic to the server with the lowest number of active connections. So, it will resolve the problem when some clients keep the session open for too long.

Weighted Least Connections (Perceptive Algorithm) algorithm does to Least Connections what Weighted Round Robin does to Round Robin. That is, it introduces a “weight” component based on the respective capacities of each server. Just like in the Weighted Round Robin, you’ll have to specify each server’s “weight” beforehand. A load balancer that implements the Weighted Least Connections algorithm now takes into consideration two things: the weights/capacities of each server AND the current number of clients currently connected to each server.

 

Advertisements
Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s