Everything you should know about the load balancer

Every computer comes with a limited computing power. It is very much difficult for a computer to perform once request load increases. Many big companeis like Amazon, Google etc uses the load balancer in order to serve billions of users.

What is the load balancer?

Load balancer is a middle layer between client & server. It balances the load on the server. It helps to distribute the load across multiple resources. Also, it keep track of status of all the resoruces while distributing requests. In case of any server is down or unavailable, Load balancer stop sending the traffic to that server.

Where to use the load balancer?

Load Balancer can be added anywhere is system design. Geneerally we use them:

  • Between user & web-server
  • Between web-servers & internal servers (application servers or cache servers)
  • Between Internal platform layer & DB

Types of load balancers

There are three types of load balancer are available.

1. Hardware load balancer:

Hardware load balancer is one the expensive load balancer. Even big companies avoid them due it cost & maintainance. They use them only as first point of contact & use other machanisms for load-balancing.

2. Software Load balancers:

Software Load balancers is one of the popular load balancer due to it’s hybrid approach. It uses the software which transefers the load smartly on the servers. HAProxy is a popular open source software for load balancer. Every client request on this port (where HAProxy is running) will be received by proxy & then passed to the backend service in efficient way. HAProxy manages health check & will remove or add servers.
Smart client is also used in load balancing. It’ll take a pool of service hosts & balances load, manage them (Detect recovered host, deal with adding new hosts, etc). Read more about this from this link.

Load balancing Algorithms

  • Round robin
  • Round robin with weighted server
  • Least connection
  • Least response time
  • Source IP hash
  • URL hash