Hi! I am LB. Formally know as Load Balancer. In this article I’ll briefly talk about Where, What and Types of LBs.
Where??
Imagine a system with single application server serving hundreds of request. Life is easy until our product proves its worth in the market and gradually traffic starts to increase. No problem, we’ll add few resources to our single server (Vertical Scaling). Increase RAM and CPU.
Company gains traction and more investors come in, now it’s time to scale the product. One of the pressing point is the product should be highly available, that is longer down times can impact the image of company. So we quickly identify that we have a potential single point of failure in our system.
We are using a single server and what if it goes down!
In such situations obvious next step is to add more servers and let those servers also serve the incoming requests. Cool seems easy, until we realise that we have no clue of how traffic would be routed to those newly added servers?
This is where I the LB comes in to action. A LB comfortably sits between the client and application servers and route traffic based on different algorithms like round robin, least response time, etc.
LBs can sit in multiple places some of them are like
- Client and web servers
- Web and Application servers
- Application and DB servers
LBs at different layers gives us a system in which layers can be scaled independent of each other. For example we can scale up the application layer without scaling up the web servers.
What??
In simple terms I distribute traffic to multiple servers so that no one server has to take the load. Additionally, LB provide features like health checking of servers, service discovery in a distributed system, etc.
Load Balancer can be a hardware device or a software process running on some machine.
One can also improve security by deploying a LB as it prevents from attacks like DDoS.
Types
I(LB) am mainly of 2 types based on layers of OSI model
- L4 – Working at the 4th layer (Transport) where you don’t know what the request packet content is. It mainly makes routing decisions based on Network information like ports, source IP, destination IP, etc.
- L7 – Working at 7th layer (Application). This layers has access to request packets and routing decisions can be made based on cookies, headers, URLs, etc.
Conclusion
Load Balancer have become a crucial part of today’s complex systems. One can reduce latency, improve availability and secure system by efficiently using LBs.