bdurand / seamless_database_pool

Add support for master/slave database clusters in ActiveRecord to improve performance.
http://rdoc.info/projects/bdurand/seamless_database_pool
MIT License
224 stars 58 forks source link

Suggestion: peer-to-peer failover #21

Open pareeohnos opened 10 years ago

pareeohnos commented 10 years ago

On an application that I've been working on, we have a need for high availability and after discovering this gem I thought that it would be easy to implement, however I soon realised a limitation with this gem with the structure of our database setup.

Because of the need to have access to the latest data very quickly, we can't rely on replication happening before the next read, so we have all reads/writes happening on one box, with peer-to-peer replication setup between all databases. This way, if the one we're using fails, we can change connections to another and not lose anything, and just have a slight delay due to replication speeds (which we can live with in the event of a failure)

Unfortunately, seamless_database_pool only seems to allow for a master/slave configuration, with failover only applying on the slaves. In the event of the master failing, everything fails. Because our setup does not have a master, I was not able to use this gem.

Based on the code from this however I have created something that fits our needs, but it may be worth considering adding this type of functionality to this gem as it may be useful to others? Or perhaps modify it so that the entire thing doesn't fail if the 'master' fails, and a way of configuring it so that the other nodes are only used in the even of the master failing, and it then makes one of the other nodes the 'master' temporarily.