# load balance to several servers in three locations - use DNS



## jliegel (Mar 15, 2014)

Interesting problem to solve. Open to all ideas.

I have several HTTP servers for delivering video and need to balance load somewhat evenly between servers at each location; and depending on time of day balance differently between three locations of servers to use bandwidth effectively at each location.

Need to allow a server or an entire location to be down. Need my load balancing system to be in two locations. I already have DNS servers in two locations.

I looked at a few services and appliances to do this which were cost prohibitive. so i either build my own appliance (not going to compile any C code through); or use a hybrid such as the following example.

Idea: Place DNS caching servers in between Clients and DNS monitoring/load balancing system (a service charged by hits). Caching servers take the hits from clients (once every minute per client when TTL expires) and only query monitoring/load balancing DNS servers once every minute when TTL expires. Not as good as using service directly or my own appliance that does it all, but likely acceptable.

I would configure two public domain names as start of authority with my domain provider


```
NAME ----------- START OF AUTHORITY -- NOTES
MyExample.com -- NS1.MyExample.com --- Points to my dns caching servers
MyRouting.com -- NS1.MyRouting.com --- Points to dns monitoring/load balancing
```

Client’s house uses their own ISP for DNS resolution NS1.ClientISP.com.

Client plays a video vod.MyExample.com/1234.ts.

DNS sequence of operation:

Sequence 3 and 4 must be completely hidden from NS1.ClientISP.com.


```
SEQUENCE -- ACTION ---- DESCRIPTION -------- FROM --------------- TO
1 --------- query ----- vod.MyExample.com -- Client's Device ---- NS1.ClientISP.com
2 --------- query ----- vod.MyExample.com -- NS1.ClientISP.com -- NS1.MyExample.com
3 --------- query ----- vod.MyRouting.com -- NS1.MyExample.com -- NS1.MyRouting.com
4 --------- response -- 1.2.3.4 ------------ NS1.MyRouting.com -- NS1.MyExample.com
5 --------- response -- 1.2.3.4 ------------ NS1.MyExample.com -- NS1.ClientISP.com
```


----------



## kpa (Mar 15, 2014)

*Re: load balance to several servers in three locations - use*

I haven't really done anything like that myself but I'm under the impression that DNS isn't the right place to do load balancing. What is called a "reverse proxy" that hides the complexity of the load balancing behind a single DNS name is more likely the way to go.


----------



## J65nko (Mar 16, 2014)

*Re: load balance to several servers in three locations - use*

https://en.wikipedia.org/wiki/Round-robin_DNS has a reference to a Perl load balancing DNS server, but it seems to be quite old and I could not find it on CPAN.

http://www.openbsd.org/faq/pf/pools.html#incoming deals with load balancing, but assumes the servers to be in a single location. 

Some time ago somebody here mentioned  haproxy : 





> HAProxy is a free, very fast and reliable solution offering high
> availability, load balancing, and proxying for TCP and HTTP-based
> applications. It is particularly suited for web sites crawling under
> very high loads while needing persistence or Layer7 processing.



The man page: http://www.freebsd.org/cgi/man.cgi?quer ... ormat=html


----------

