What Are Load Balancers?
You've probably heard of the term Load balancers when working with Apis or servers.
Load balancers as their name suggests are used for balancing traffic and requests between servers.
A load balancer can be seen as a task distributor because it distributes operations and tasks between a network or collection of servers in a system.
So there are two major classifications of load balancers and they are:
Hardware Load Balancers
Virtual Load Balancers
We will be looking into the types and classifications of load balancers in the next sections, but for now, we explore what load balancers are and what they can be used for π
Uses Of Load Balancers
Load balancers have a lot of use cases from routing requests to acting like a traffic warden on a server network. So, these are the uses of a Load Balancer:
They Are Used For Keeping High Availability:
In most systems where there is a lot of traffic coming in, there's a high probability of downtimes and the like frequently occurring. So, load balancers are used to improve availability by reducing the loads from overloaded servers, re-routing requests to servers that are available and distributing work between servers in a balanced order.
They Are Used In Traffic Distribution Between Servers:
In most systems where there are a lot of servers (big systems like FaceBook, Google etc) Load balancers are used to distribute loads of requests coming into the system between the servers working under the hood to ensure no server is being overloaded.
π‘Did You Know?
Load balancers can protect a system against a DDOS attack(Distributed Denial Of Service Attack) π
This is possible because the load balancers would not allow the requests from the DDOS attacks to overload a particular server due to the fact they are load balancing the requests coming inπ
Types Of Load Balancers
When it comes to the types and classifications of Load Balancers, there are different types and classifications. So, we would be looking at the two major types of load balancers
Software Load Balancers
A software load balancer is a software-based load-balancing solution that is used for distributing requests and tasks between a collection of servers. As its name suggests it doesn't have any hardware component rather it exists virtually on the servers. Examples are NGNIX, HaProxy, Avi Vantage etc.
Hardware Load Balancers
Unlike the software load balancers, the hardware load balancer is a physical server that is dedicated to rerouting requests and distributing tasks between a collection of servers. It is just a Proxy.
Load Balancing Algorithms
There are different algorithms load balancers use to distribute tasks between servers efficiently to ensure there's no overloading or imbalance in the system.
Some of the major algorithms are:
Random Selection Algorithm: This algorithm randomly selects the server to give tasks. This algorithm is not efficient because a server can be easily overloaded especially in events such as DDOS attacks.
IP Hashing Algorithm: This algorithm uses a mathematical function to hash the client's IP and reroutes its requests to a server resonating with the hash. This one works more with systems with regional servers, meaning it gives the client to the server closest to it.
Least Connection Algorithm: This algorithm checks for the server with the fewest connections and routes the requests to it for further processing. This is one of the most efficient algorithms for load balancing.
Thanks for reading to the end, I'll see you on the next oneπ