Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to reconfigure a prod env to provide hot failover for a db driven web app written in Perl that is currently running on an Apache HTTPD server, on a Linux OS.

The app is not designed to run in a cluster. Thus, if 2 instances of this app are connected to the same db and exposed to users via a NLB it would result in disaster (a logically corrupted db).

I would like to configure different db credentials for two app instances put under an Apache mod_proxy NLB installed on a 3rd machine. Normally, instance 2 would be shutdown and instance 1 would handle all the load. When something goes wrong with instance 1, I would need a script to send a shutdown command to instance 1, connect to the db and disable instance 1's db credential, restart the db server and finally start instance 2. If anything goes wrong in this chain of events I would be happy for the app to remain unavailable to users.

The problem is that I don't know of an easy way to configure this hot failover scenario. I would be happy to glue a shell script to mod_proxy but don't know if that's possible.

Can it be done without configuring an additional monitoring system that would detect the problem and trigger the required actions?

share|improve this question

Why try to recreate the wheel? There are lots of perfectly good failover solutions with proven stability records. For example, use Pacemaker to control starting/stopping your services and Heartbeat to detect the health of you servers.

If all you're trying to guard against is failure of one of your Apache front-end servers then you could use a load balancer like haproxy instead. Haproxy can be configured to only use one server as a primary, a fall back to a single web server. Like so:

listen externalwww
        mode    tcp
        option  persist
        option  httpchk
        default-server  inter 5000
        server  external check port 80 inter 15000 rise 10
        server  internal check port 80 backup
share|improve this answer
Because neither of these is trivial to setup/configure. On the long run they are definitely the way to go. But I'm a dev, not a sysadmin and only need to provide a temporary solution. Ideally, I would like to piece together this solution ASAP and learning these specialized tools is non trivial to say the least. – bogdan Jan 28 '13 at 16:43
You're going to spend more time piecing something together than it will take you to set up Pacemaker and Heartbeat. But how about haproxy? See my edit for an alternative solution. – longneck Jan 28 '13 at 16:51
The core of my problem is that I need to run a script when the balancer detects failure. Only through a script I can ensure everything happens in the exact sequence that I need. Can haproxy run a script when it detects failure of a member server? – bogdan Jan 28 '13 at 17:09
You're going to spend more time piecing something together than it will take you to set up Pacemaker and Heartbeat. – longneck Jan 28 '13 at 17:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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