Question

More and more of the noSQL databases that are in the spotlight uses the master/slave pattern to provide "availability", but what it does (at least from my perspective) is creating the weak link in a chain that will break anytime. - Master goes down, slaves stops to function.

It's a great way to handle big amounts of data and to even out reads/writes, but seen in an availability perspective? Not so much...

I understand from some noSQL's that the slaves can be changed to be a master easily, but doing this would be a headache to handle in most applications. Right?

So how do you people take care of this sort of stuff? How does master/slave-databases work in the real world?

Was it helpful?

Solution

This is a fairly generalized question; can you specify what data stores you're specifically talking about?

I've been working with MongoDB, and it handles this very gracefully; every member in a "replica set" (basically, a master-slave cluster) is eligible to become the master. On connecting to a replica set, the set will tell the connecting client about every member in the set. If the master in the set goes offline, the slaves will automatically elect a new master, and the client (since it has a list of all nodes in the set) will try new nodes until it connects; the node it connects to will inform the client about the new master, and the client switches its connection over. This allows for fully transparent master/slave failover without any changes in your application.

This is obviously fine for single connections, but what about restarts? The MongoDB driver handles this as well; it can accept a list of nodes to try connecting to, and will try them in serial until it finds one to connect to. Once it connects, it will ask the node who its master is, and forward the connection there.

The net result is that if you have a replica set established, you can effectively just not worry that any single node exploding will take you offline.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top