FAQ: Distributing HTTP requests with Round-Robin DNS
The Round-Robin DNS solution is recommended only if a hardware-based loadbalancing solution is unavailable. Round-Robin DNS is a mechanism for cycling through a list of Web server IP addresses for a single Web host name.
Suppose that you have two Web servers, www1.yourdomain.com (192.168.1.10) and www2.yourdomain.com (192.168.1.20), and you want to balance the load for www.yourdomain.com on these two servers by using the Round-Robin DNS trick.
Just follow these steps:
1. Add the following lines to your yourdomain.com zone file:
www1 IN A 192.168.1.10
www2 IN A 192.168.1.20
www IN CNAME www1
www IN CNAME www2
2. Restart your DNS server and ping the www.yourdomain.com host. You will see the 192.168.1.10 address in the ping output.
3. Stop pinging and then start pinging the same host, and youíll see the second IP address being pinged, because the preceding configuration tells the name server to cycle through the CNAME records for www. In other words, the www.yourdomain.com host is both www1.yourdomain.com and www2.yourdomain.com.
When someone enters www.yourdomain.com, the name server gives out the first address once, then gives out the second address for the next request, and keeps cycling between these addresses.
A disadvantage of the round-robin trick is that the DNS server has no way of knowing which system is heavily loaded and which is notóit just blindly cycles. If one of the servers crashes or becomes unavailable for some reason, the round-robin DNS trick still returns the broken serverís IP on a regular basis. This means that some people will be able to access the sites and some wonít.
How can you mirror the same content of a website on 2 different hosts and if one host fails, then the user is automatically directed to the second host. The first server will be used as a regular option meaning this has more power and bandwidth, and the second one is just backup in case the first one is down.
Is this possible? If so how? If not, what are the alternatives to avoid a down site (for small/medium websites), other than load balancing which is expensive and small websites cannot justify the costs of load balancing?
You can use a failover service like zoneedit offers or build it yourself. Basically, ping your servers every x minutes, if one of them does not respond, take it out of the round robin rotation. You could get more complicated and take server load readings and then "weight" it somehow, but if you are looking for cheap, go with zoneedit.
"First, load balancing is only performed once for each client at the beginning of a session.
Second, it's possible for the load balancing scheme to get a little skewed.
For instance, all the users that have been sent to MyServer1 may go to lunch while all the users who have been sent to MyServer2 continue to send requests. In this case, one server could become overloaded while another server is sitting by idly.
Third, A more significant problem with session-based load balancing is that it exposes the IP addresses of the servers in the farm to the client-side browser.
What happens when a server crashes or is taken offline? Your balancing algorithm needs to account for this as soon as possible, but doing so can be problematic. If you're passing out bad IP addresses, your users will start to receive "server not available" errors.
In a round-robin DNS system, it still can take as long as 48 hours to fix the problem once you've discovered that one of your servers has crashed.
This is due to the fact that the changes to your IP address mappings need to be propagated to DNS servers throughout the Internet."
1. The time to live (TTL) on the zone files needs to be turned down severely to to reduce the time for which results are cached.
The longer the TTL, the less control there is over which IP addresses that end-users are accessing. The shorter that TTL, the greater the potential for congestion on the DNS server.
2. Users may access servers using an IP address rather than a host name.
3. Users may use non-DNS methods such as an /etc/hosts file to map server host names to IP addresses.
4. An additional problem with round-robin DNS is that the DNS daemon cannot differentiate between a request for a one-off hit, and a request that will result in many hits. That is, it is hard to control the granularity of scheduling.
5. When using round-robin DNS there is no way to assign weights to servers, all servers will theoretically receive the same number of requests, regardless of their resources and current load.