D. J. Bernstein
Internet publication
djbdns

How to balance load among many web servers

These instructions assume that you are already running tinydns, version 1.04 or later, as a DNS server.

Suppose you have 50 identical www.heaven.af.mil web servers running on IP addresses 1.2.3.150, 1.2.3.151, and so on. You can simply list all their addresses in /service/tinydns/root/data:

     +www.heaven.af.mil:1.2.3.150
     +www.heaven.af.mil:1.2.3.151
     +www.heaven.af.mil:1.2.3.152
     # etc.
When a DNS cache asks for the IP address of www.heaven.af.mil, tinydns will automatically return a random set of 8 addresses.

If one of your web servers crashes, the effect on users will depend on how their browsers behave:

You can eliminate delays by removing IP addresses of web servers that have crashed. tinydns is designed to work with external programs that monitor the health of your servers. Specify each address with a 5-second TTL:

     +www.heaven.af.mil:1.2.3.150:5
     +www.heaven.af.mil:1.2.3.151:5
     +www.heaven.af.mil:1.2.3.152:5
An external program can remove an address by simply changing + to - on the relevant line, then running make. Later, when that server has recovered, the program can change - back to +.