views:

40

answers:

1

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?

+4  A: 

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.

Chris Heald
Hi Chris, thanks a lot for the great answer. MongoDB seems like a great product that used in production by several sites as one of the most popular products being mentioned when someone says noSQL. I had no idea about mongoDB working totally alone on the master/slave part, so this has really opened my eyes. I will definitely check out mongoDB closer now!
Industrial
Hi again Chris. Would you care to tell how you have set up your replication? Is it only the "slaveof" line in the configuration file that is needed?
Industrial
@Industrial see http://www.mongodb.org/display/DOCS/Replica+Sets for info on setting it up. If you just use --slave it won't do automatic failover.
kristina