DEV Community

Vishesh
Vishesh

Posted on • Updated on

What is a load balancer

Load balancer is a industry standard now in software server architectures. In current generation systems atleast which I was building. There is increasing need to keep the servers reliable and with 24*7 available. This is where load balancers come to place. As the name suggests a loadbalancer is used balance the server load.

Traditional server system

Consider you are running a server in production and now your client has 2 customer using the server. Soon its good times and number of customers increase. Then the server load will increase. This might cause the server to go down.
Forcing you to restart and fix the issue. Thus their will be down time and that marks your end. Escalations, mails, late nights, etc... Clearly this is not a good structure.

Alt Traditional server

Server system with load balancer

  • Instead of a single large server. We will have to create two medium capacity servers that are capable of running the server.
  • Create a load balancer
  • Attach the servers to the load balancer

Alt Text

How the load balancer works

Just as a traffic police officer the load balancer will be the first layer that receives the server request. Then it will direct to the server. In background the load balancer will be monitoring the server to check if its up by hitting any API in your server. If the API responds with 200 its fine else it will consider the server is down.

Therefore when the one server is busy like 100% utilisation or is its down. Then it will send the request to server 2 automatically. This is a minor setting but a major improvement on server availability. Of-course there are few disadvantages,

Disadvantages

  1. You will have to run application in multiple servers.
  2. You cannot use local server storage. Since there are two servers and you will never know which server the request will land.
  3. Logs will be separate in both of the servers.

Personally i avoid using local system but in-case i need to use, i will go with S3 or other cache services like Redis, elastic cache, etc. There is a ton of info on how to do in AWS below are the reference links.

Reference Links

Create AWS Load balancer: https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-create-https-ssl-load-balancer.html

Top comments (0)