So, the term Load balancer comes from the late 1990s when companies technology companies couldn't handle the bulk of traffic in single mainframe computers and they really don’t have a budget to buy a new one.
A Load Balancer is a device which acts as a reverse proxy and distributes over a network or application traffic across the servers. Just like below the image.
So, What Load Balancing actually does ??
In more technical language, A load balancer acts as the “traffic cop” sitting in front of your servers and routing client requests across all servers capable of fulfilling those requests in a manner that maximizes speed and capacity utilization and ensures that no one server is overworked, which could degrade performance. If a single server goes down, the load balancer redirects traffic to the remaining online servers. When a new server is added to the server group, the load balancer automatically starts to send requests to it.
In nowadays, Load Balancer in every large scalable distributed system is now the necessity, form every video streaming platform to E-commerce platform you will saw Load Balancer in their system design. for eg. Facebook, Amazon, Airbnb, Netflix, Youtube, Google & etc. Load Balancing is now a critical part of system design nowadays you should How it works or runs.
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 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).
The most commonly used is Consistent hashing,
Benefits of Load Balancing
- Reduced Downtime
- Global Server Load Balancing
And for detailed
Here is my full medium article link