I've got two servers, equal capabilities in terms of processing power and load. What I am trying to accomplish is this: (I already own and run DNS servers so this shoudln't be a problem).

Server A will serve ALL incoming requests to sub.domain.com Server B will ONLY serve while server A is down, and if it needs to wait a few moments to decide, thats OKAY.

Is it possible? The weighted round robin doesn't work for what I need, nor does regular round robin, since it will only advance to the next server if the first request is successfully delivered.

Is there a way to make it so that if sub.domain.com on server A is unavailable, forward to server B until A comes online?

Thanks, this will really help with the consistency of my project.

  • It's not DNS round robin if you're not serving the responses in a ROUND ROBIN fashion. – womble Jul 30 '11 at 0:57

Is there a way to make it so that if sub.domain.com on server A is unavailable, forward to server B until A comes online?

Not via DNS - at least not without a custom DNS server monitoring and changing records on the fly (which wouldn't work too well). To get this behavior, you'll need a system in between the clients and the servers handling the failover logic. HAProxy is always a good option, and assuming it's http traffic, several flavors of common web servers (Apache, nginx, lighttpd) could also do what you need.

  • Mmmm..... this is not HTTP traffic. It's just raw TCP data. Sorry. – U4iK_HaZe Jul 29 '11 at 19:29
  • 2
    HAProxy, then. It can handle raw TCP. – Shane Madden Jul 29 '11 at 19:31

Another option is something like CARP. You assign a virtual IP address to both servers, and they ping each other periodically and as long as the 'master' is up, it will get the traffic, but if it stops responding, then the slave takes over that ip. This makes it entirely transparent to the applications.

CARP - Common Address Redundancy Protocol

  • Thanks for your comments. I'll set that up some time next week. – U4iK_HaZe Jul 31 '11 at 4:45

F5 GTMs do exactly this, among other things. They do tests on devices to see if they are up, and then change the DNS records to the appropriate value.

If you're feeling particularly adventurous you could allow dynamic updates of your DNS zone. Then from host B do checks against host A using some kind of script. If it detects host A is down/unreachable/unresponsive, it can send a DNS update request to change the IP. Host A can do the inverse, and automatically set the DNS record back to its IP after a certain time of "upness".

You can also swing with the options of HAProxy, or other high availability options such as CARP, or look at the Linux-HA.org site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.