I recently bought a second webserver because I worry about hardware failure of my old server. Now that I have that second server I wish to do a little more then just have one server standby and replicate all day. As long as it's there I might as well get some advantage our of it !

I have a website powered by ubuntu 12.04, nginx, php-fpm, apc, mysql (5.5) and couchdb.

Im currently testing configurations where i can achieve failover AND make good use of the extra harware for faster responses / distributed load.

The setup I am testing nowinvolves heartbeat for ip failover and two identical servers. Of the two servers only one has a public ip adress. If one server crashes the other server takes over the public ip adress. On an incoming request nginx forwards the request tot php-fpm to either server a of server b (50/50 if both servers are alive). Once the request has been send to php-fpm both servers look at localhost for the mysql server. I use master-master mysql replication for this. The file system is synced with lsyncd.

This works pretty well but Im reading it's discouraged by the (mysql) community.

Another option I could think of is to use one server as a mysql master and one server as a web/php server. The servers would still sync their filesystem, would still run the same duplicate software (nginx,mysql) but master slave mysql replication could be used. As long as bother servers are alive I could just prefer nginx to listen to ip a and mysql to ip b. If one server is down, the other server could take over the task of the other server, simply by ip switching.

But im completely new at this so I would greatly value your expert advice. Is either of the two setups any good ? If you have any thoughts on this please let me know !

PS, virtualisation, hosting on different locations or active/passive setups are not solutions im looking for. I find virtual server either too slow or too expensive. I already have a passive failover on another location. But in case of a crash I found the site was still unreachable for too long due to dns caching.


We do it on all our customer HA boxes and our Magento MicroCloudTM/ configurations, so that the fail over system(s) isn't idle. Look into DRBD, Linux VServer and heartbeat.

Read the following for an insight into it.


Caveat But as always, we advise not trying to do this unless you have substantial experience, as you are more likely to end up with a more unreliable configuration, that is harder to debug and if you end up in a split brain situation, more likely to have data loss ... than a plain old single server.

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.