What is Load Balancing?
Let’s imagine we have a web application on a server (webserver) that’s working fine for 100 users. Users simply go to fabapp.com to access this hypothetical web application. This sort of setup has two possible problems:
- What would happen if the webserver blows up? Those users wouldn’t be able to use the application. In other words, we need resilience.
- Say, 100 more users have decided they like the look of this web application and want to use it. The web server is going to struggle to deal with all these users. In other words, we need more capacity which can also help improve performance.
The solution is to add another web server and when users visit fabapp.com we automatically want to send some users to the first web server and some users to the second web server without them ever really knowing anything has changed in the background. This is load balancing i.e. distribute incoming traffic to a group of backend servers.
We’ve talked about what we want to do i.e. load balance, and what effect that will have but we’ve not talked about how to do it. In this article, we will only cover the most basic kind of load balancing - DNS load balancing.
DNS Load Balancing
No idea what DNS is? Click here for my Ultimate Guide to DNS. Basically, DNS is used to look up the IP address of a server from the web address; like a phonebook is used to find the phone number given the name of the person.
A DNS record can be associated with one or more IP addresses - this is how DNS load balancing can happen. fabapp.com’s DNS record would be configured to point to 2 servers. When a DNS request is made, by a users computer trying to access fabapp.com, DNS will return any one of the 2 IP addresses randomly. The users computer will then directly connect to the IP address it was provided. Effectively this will split the load between the two servers aka load balancing!