What is Load Balancer and How it works ?

Photo by Egor Myznik on Unsplash

What is Load Balancer and How it works ?

What is load balancer and how it works ?

  • routing traffic from the client --> Server, acting as a cop in between
  • Server will have now the private IP and the Load balancer will have the public api and this load balancer will route the traffic to the server
  • LB increase Scalibiity and Availibility, Convience or flexibility of routing the traffic from the LB to the invididual server
  • LB prevent server load
  • LB route trafic

L4 : layer 4 of OSI model, there are load balancer which works on this layer. it will route the traffi based on TCP or UDP ports along with source and destination IP address. it performs NAT ,

  • L7 : it will act on layer 7, application layer, they can check more information such as HTTP Headers, Session Id

Load Balancing Algorithms

Different load balancing algorithms provide different benefits; the choice of load balancing method depends on your needs:

  • Round Robin – Requests are distributed across the group of servers sequentially.
  • Least Connections – A new request is sent to the server with the fewest current connections to clients. The relative computing capacity of each server is factored into determining which one has the least connections.
  • Least Response Time – Sends requests to the server selected by a formula that combines the
    fastest response time and fewest active connections. Exclusive to NGINX Plus.
  • Hash – Distributes requests based on a key you define, such as the client IP address or
    the request URL. NGINX Plus can optionally apply a consistent hash to minimize redistribution
    of loads if the set of upstream servers changes.
  • IP Hash – The IP address of the client is used to determine which server receives the request.
  • Random with Two Choices – Picks two servers at random and sends the request to the one that is selected by then applying the Least Connections algorithm (or for NGINX Plus the Least Time algorithm, if so configured).