0

I should emphasize that my question is in regard to CP (Consistent and Partition Tolerant) systems.

A lot of widely used NoSQL databases such as Mongo and Redis seem to fall in the CP category. And in addition to that, RDBMS's such as SQL Server and MySQL can also be configured to operate in a CP multi-master mode.

Two arguments I could find on the Internet are:

  1. Load balancing write queries
  2. Decreasing downtime in case of failure of a Master

I have doubts about the first reason because as far as I understand, in order to maintain data consistency between these Master replicas, the write operation should take place in every Master. If so, that will create the same burden for all the Masters plus the overhead associated for synchronization.

What are the solid reasons for such systems? Or am I missing something?

  • Your question could use some clarity: I think you are asking about CP architecture (single primary) versus AP (multi-master). The CAP theorem implies a choice between consistency and availability in the event of a network partition. The two points you've mentioned are about availability rather than consistency, but don't mention the tradeoffs (conflict resolution and eventual consistency). Note: it would be helpful to link the related discussions for context. For a similar question, see: Mongo CP, Cassandra AP?. – Stennie Oct 9 '18 at 5:07
1

The two arguments you mentioned are independent of weather the system is CP or AP. They are advantages in general for any distributed system with replication. Let's stick to CP as that is the main topic. In a CP distributed system, with replication factor 2, the write should finish on 2 nodes before the client is acknowledged of the write. So, yes that overhead of writing on multiple nodes and the synchronisation is present. But that distributed system may have 50 nodes. The writes will be load balanced across those 50 nodes. And because the replication factor is 2, even if 1 node is down, the reads and writes can continue without any down time.

why CP then ? Putting in a very very naïve way, CP will never loose acknowledge write but AP can loose acknowledged write in a split brain situation. Also, CP will guarantee that if an application updates a value from A to B, a subsequent read by it will always read B. But in an AP system, it may read either A or B. A CP system will deny a write or read if it cannot guarantee its consistency. An AP is system is more relaxed about it. This can be a pretty big deal depending on the type of application. For e.g. if the application is tracking the number of likes, its probably ok to loose a few in a worst case scenario. If the application is dealing with user's money, it should be accurate in all scenarios. Such applications are typically ready to pay the extra overhead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.