Load Balancing Algorithm

Static Algorithms

Round robin

Distribute requests evenly in each server
Pasted image 20230902103124.png

Pros

  • Easy to do
  • Make sure all the requests get routed properly
    Cons
  • If one server is temporary unavailable and get back up again, caused inbalancing in distribution
  • The routing is not necessary optimised for the connection

Sticky round robin

Pasted image 20230902103246.png

Same request goes to the same servers.

Pros:

  • Server contains information for the relevant requests, hence make it more suitable to handle requests from the same server.

Cons:

  • Could happen unbalance distribution where one users make more requests than the other users.

Weighted round robin

Pasted image 20230902103657.png

Each server has a weight of distribution and request can distribute there.

Pros:

  • Have more control of the distribution
    Cons:
  • Weighted attributes needs to be monitor and configure manually

IP/URL Hash

Pasted image 20230902103807.png

We route each request IP to the corresponding server.

Pros:

  • Provide a control over which IP goes to which server
    Cons:
  • Unbalance distribution
  • Hash function is difficult to calculate

Dynamic algorithms

Least connections

Pasted image 20230902104304.png

Routes to the server that currently has the least connection

Pros:

  • Properly distribute all the requests to server.
  • Dynamically adjusted base on the need

Cons:

  • Need to monitor the connections for each server which requires resources.

Least latency

Pasted image 20230902104714.png

Route to the nearest server based on the user latency.

Pros:

  • Highly adaptive and reactive
    Cons:
  • Introduce complexity
  • Constant monitoring
  • Doesnt monitor how many requests the server currently have.