Load Balancer

Websites may be in need of serving millions of incoming requests from clients.
This high traffic leads us to scale the web application horizontally by adding more servers to the server pool.

At this point, the network traffic should be directed to the servers in a way of well-balanced and this is called load balancing.
A load balancer makes this balanced distribution of network traffic across servers.

A load balancer may be of the form of a physical hardware device or a software.

Load balancers mainly enable horizontally scaling with which the following benefits are implicitly gained:
  • minimizes server response time
  • maximizes throughput
  • prevents bottlenecks
  • avoids single points of failure 

Load balancing algorithms

Round Robin
In Round robin load balancing; the requests are distributed sequentially to the servers.
Round robin load balancing is easy to implement however it has a drawback that long-running requests are not taken into account and this leads the balance to be lost.

Least Connections
In this method, an incoming request is directed to the server which has the least active connections and so more balanced way of direction is provided.

Hashing Method
The ip address of the client or data such as URL or header information from the incoming packet is hashed and used to decide where the requests to be directed.

And some other algorithms are;
   - Least Response Time
   - Least Bandwith
   - Weighted Round Robin
   - Weighted Least Connections
   - Agent-Based Adaptive Load Balancing
   - Layer 7 Content Switching
   - Global Server Load Balancing (GSLB)



Dependency Injection In Java and CDI

Java EE Technology Stack