LoadBalancer | System Design Part - 3
This is part 3 of the SYSTEM DESIGN SERIES. where we will be discussing about LoadBalancer.
From the previous parts (Single Server Setup / Databases), we have had an understanding of how the request traverse from user to a web server and to the database, Now let's check whether our system is capable of providing failover or how it handles if the webserver goes down
With the increase in the traffic, the load on the server will be drastically increased and it leads to more latency in the requests. which will impact the user experience or the server gets crashed because of a high bump in the traffic.
If the server is offline in that case, the user will not be able to access the website.
To avoid this we can add multiple servers, but how come can we route the user requests to the servers which we have added?
Here comes the LoadBalancer, It will help us in routing the user requests to the right server based on the availability and load on the server.
After introducing a load balancer, the end-users cannot access the web servers directly. They can access the load-balancer which will internally call the webservers.
For security reasons, it is advisable to make the webservers have private IPs so that no one from outside the network can access the servers.
From the above picture, we can see that the web servers are having private IPs and the load balancer is having public IP. which is internally allocating the requests based on availability. With this setup, we can resolve the failover issue and improve the availability of the servers.
- If one server fails or down, all the requests will be routed to the second server and a new healthy server will be created in that place
- Over a period of time if there is more traffic, and if the existing servers are not enough to handle the load, we can simply add new servers. Load balancer can gracefully identify those servers and start sending requests to them.
In our current design, we have only one database, which cant handle failover and redundancy, most commonly used approach to address this problem is by DATABASE REPLICATIONS, Lets look into that in our next article.
Comments
Post a Comment