What is a load balancer, and why do scalable systems need it?

When you open a browser or an app, the request does not go directly to the server. In modern systems there is more than one server working together, it goes to a load balancer, which routes your request to a healthy and reliable server, and the server processes it and sends back a response through the load balancer.
What is a load balancer?
A load balancer is either hardware or software, in modern technology it is software that does the single job of distributing traffic across servers. Think of it as a restaurant where there are many chefs, a host gets orders and assigns them to the appropriate chef. He does not take orders himself, but his only job is to assign orders to the correct chef. Similarly, a load balancer takes all the requests and routes them to different servers.

Why do scalable systems need it?
A load balancer is a core component of scalable systems, a system without a load balancer is very hard to scale. Because some of the servers will be idle and some will be overwhelmed by requests. Below are some of the advantages of a load balancer in a scalable system:
No single point of failure: If any server goes down, it will not affect the application because requests will be routed to the healthy servers.
Easy scaling: Adding a new server to the system is easy, when a new server is booted, the load balancer automatically detects it and starts routing requests to it also.
Better performance: When traffic is distributed, servers are not overloaded hence, they perform better.
Conclusion
A load balancer is an essential component of a scalable system that works like a traffic police officer who routes the traffic across different lanes (servers) to avoid traffic jams. It distributes traffic across different servers, constantly checking if the servers are healthy, makes adding new servers into the system easy and more.




