i am building a system for a client that uses a mysql database with master/slave replication. its not a question of load, but of using replication as an efficient way to back up a really big database. i want my rails app to fail over automatically from the master to the slave in the event that the master goes down. is their some existing and accepted way of doing this in rails?
Maybe this link will be of some help:
For automatic fail over of servers, I usually use ucarp: "http://www.ucarp.org/project/ucarp.":http://www.ucarp.org/project/ucarp Of course if you are on OpenBSD you don't need it because carp is part of the OS.
It is an excellent, lightweight, portable and simple solution. Linux Virtual Server works for high availability, but is overly complex.
However, be careful, because the defaults will allow the computers to trade being Master back and forth (i.e. computer a reboots, computer b is master, then later on, computer b reboots, computer a would be master). So, you must configure your up scripts to do something creative like reconfigure and restart ucarp to be the preferred master on the slave, or, gracefully bring slaves into the farm. It should be possible to use the up/down scripts to rebuild replication on whatever happens to be a slave and make it play nice as a mysql replication client. Because of these complexities and the enterprise requirement of 0 data loss, I have often set up fault tolerant hardware for the DB server (RAID, dual power, dual CPU, hot swappable components, etc.) and used a human to handle fail over of the DB server to the replication backup, and then use ucarp in conjunction with load balancing (pound for example) for all the web servers. However, some scripts to gracefully bring servers into a farm as a slave in conjunction with ucarp would be a sweet setup indeed...
Wow I have to check some of this stuff out for my own uses.
What I've done is much simpler on my end. I just use a load balancer in front of my servers. Then if one server becomes unresponsive then the load balancer handles the trade off. Not sure this is the best way though. I'll have to review the other advice given here to see.