How to configure db redundancy?

Hi,

I have a rails application, part of which reads data from a slave. There
is two slaves which is available for it to read from. Problem is, the
replication occasionally stops on either of these slave.

Therefore, I would like to set up the application with a recurring rake
task that checks if replication has stopped on the slave it currently
uses. If so, it should switch to the other slave and begin using that
one.

I could do this by cycling to database.yml files, and renaming them /
rebooting the application when the replication stops. But that’s a very
ugly solution - does anyone know a better way to do this?

Thanks
/Markus

You should have a look at mysql proxy… Should be able todo what you
are looking for. Not using Rake but using the proxy.

http://forge.mysql.com/wiki/MySQL_Proxy