System Design - Load Balancers
Author: Al-mamun Sarkar
Date: 2020-09-17 06:00:45
A load balancer is being used to distribute load across multiple servers or resources. In this session, I will show you where we need to use a load balancer and type of load balancer as well as the algorithms used to implement a load balancer.
Why Load Balancers:
When a single server can't handle requests then we need to add multiple servers for handling those requests. A Load Balancers distribute these requests across multiple servers so that a single server doesn't need to handle all requests. A load balancer is also being used to check all the resources or servers. If a server is unavailable then it stops sending requests to that resource or server.
Where load balancer is used:
- User to the webserver (Frontend or Backend)
- Web Server to Internal server (Any other services)
- Internal server or backend to database
Types of Load Balancers:
There are mainly two types of load balancers.
- Hardware Load Balancer: Hardware is being used to distribute loads. It's very expensive.
- Software Load Balancer: It is a hybrid approach and software is being used to distribute loads. HAProxy is popular open-source software.
Algorithms of Load Balancers:
- Round Robin Algorithms.
- Weighted Round Robin Algorithms.
- Least Connections Algorithms.
- Least Response Time Algorithms.
- Source IP or URL Hash Algorithms.