tags:

views:

53

answers:

1

I've heard about two kind of database architectures.

  • master-master

  • master-slave

Isn't the master-master more suitable for today's web cause it's like Git, every unit has the whole set of data and if one goes down, it doesn't quite matter.

Master-slave reminds me of SVN (which I don't like) where you have one central unit that handles thing.

Questions:

  1. What are the pros and cons of each?

  2. If you want to have a local database in your mobile phone like iPhone, which one is more appropriate?

  3. Is the choice of one of these a critical factor to consider thoroughly?

+3  A: 

We're trading off avaiability, consistency and complexity. To address the last question first: Does this matter? Yes very much! The choices concerning how your data is to be managed is absolutely fundamental, and there's no "Best Practice" dodging the decisions. You need to understand your particular requirements.

There's a fundamental tension:

One copy: consistency is easy, but if it happens to be down everybody is out of the water, and if people are remote then may pay horrid communication costs. Bring portable devices, which may need to operate disconenected, into the picture and one copy won't cut it.

Master Slave: consistency is not too difficult because each piece of data has exactly one owning master. But then what do you do if you can't see that master, some kind of postponed work is needed.

Master-Master: well if you can make it work then it seems to offer everything, no single point of failure, everyone can work all the time. Trouble is it very hard to preserve absolute consistency. See the wikipedia article for more.

Wikipedia seems to have a nice summary of the advantages and disadvantages

Advantages

  • If one master fails, other masters will continue to update the database.

  • Masters can be located in several physical sites i.e. distributed across the network.

Disadvantages

  • Most multi-master replication systems are only loosely consistent, i.e. lazy and asynchronous, violating ACID properties.

  • Eager replication systems are complex and introduce some communication latency.

  • Issues such as conflict resolution can become intractable as the number of nodes involved rises and the required latency decreases.

djna
CouchDB uses MVCC. Does this sort of handle the consistency problem faced upon multiple masters cause when one i brought online again, the versioning system handles the consistency and this master will get the correct updated data.
never_had_a_name
But what happens when two users do something contradictory - like two users attempt to buy the last item in stock? Imagine a scenario where we have two masters and each user is hitting a different master, then we get some sort of conmmunications glitch - in the end there will either be a compromise of integrity, or reduced availability - one user get's told "sorry mate, I really don't know what's happening until I talk to the other master", or we have a nasty conflic when comms are restored - and those can get really complicated.
djna