How to set a simple load balancing with DNS, even Google does it.
In this example we will setup load balancing for domain test.com with 3 web servers.
Here's all what you will need:
- Multiple A records for host name or domain in the DNS service of your choice
- 3 VPS or Dedicated servers (even shared hosting account are fine)
Firstly to have a good load balancing you need to have a good, reliable and stable dns provider with multiple DNS servers.
With your Domain provider for domain in our example test.com we will set A record with the following IP's.
- VPS1 IP: 107.203.104.34 (server location Germany)
- VPS2 IP: 5.42.34.205 (server location US)
- VPS3 IP: 35.42.34.205 (server location Japan)
Now you need to set A record for each of this IP addresses.
After you have done that test your DNS records, you should have them displayed similar to google's.
Test and compare:
dig a google.com
Example output of google.com
;; ANSWER SECTION: google.com. 268 IN A 208.117.229.245 google.com. 268 IN A 208.117.229.250 google.com. 268 IN A 208.117.229.244 google.com. 268 IN A 208.117.229.248 google.com. 268 IN A 208.117.229.249 google.com. 268 IN A 208.117.229.247 google.com. 268 IN A 208.117.229.246 google.com. 268 IN A 208.117.229.251
Notice also that Google is using a 100-300 second TTL on its “A” records. This helps (but does not eliminate) client-side DNS caching that can lessen the effectiveness of the round-robin DNS load balancing.
For most purposes you don’t need to have a TTL that low, however. A TTL of 10 to 30 minutes is fine for most websites.
Each time you execute this command your first A record will be on the other server ip.
The order in which IP addresses are returned varies by the DNS server and provider used but often follows a round-robin or geographically specific algorithm.
The idea here is that different clients will get different ordered lists of IP addresses corresponding to your domain name. This has the effect of distributing requests across the group of IPs in a specific manner. If an IP address does not respond in an appropriate amount of time, the client will time out on that request and move on to the next IP address until the list is exhausted or it finds a connection that's valid.
Now don't forget that you need to have your website uploaded on all 3 servers.
For assistance you can contact our support
http://centos-webpanel.com/contact