2 servers, high availability and faster response

Posted by user17886 on Server Fault See other posts from Server Fault or by user17886
Published on 2012-09-21T19:53:18Z Indexed on 2012/09/21 21:42 UTC
Read the original article Hit count: 133

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.

© Server Fault or respective owner

Related posts about nginx

Related posts about high-availability