Reputation: 10538
After reading couple of articles on google, I See NoSql DB like Mongo is designed for CP(in CAP) while cassandra is designed for AP(in CAP)
Here is my question:-
Can't Mongo be configured to provide AP instead of CP or Is it rigidly designed for the CP ? Same is true for Cassandra ?
Upvotes: 3
Views: 2810
Reputation: 2055
MongoDB can never be AP as it's a leader based system. There could be 2 scenarios:
In the case of Cassandra, as Alex said we can make Cassandra more consistent by compromising availability.
Read this article, for a detailed explanation.
Upvotes: 0
Reputation: 133
Our understanding of CAP theorem has changed considerebly since its first appearance in 2000. There were a lot of confusion about the "chose-2-out-of-3" concept but Eric Brewer's article in 2012 nicely eliminated these confusions (I guess).
So, CAP theorem is not about being CA or AP or something else. It is simply this: Network partitions may happen all the time. It is unavoidable. And when a network partition happens, the architecture of a distributed database should allow its clients to tune consistency and availability as they wish.
What does this mean? Assume that you replicate a piece of data between 3 nodes (N1, N2, and N3 - so replication factor = 3) in a cluster. And let's say that a network partition happens which seperates N3 from N1 and N2:
So, all of the 3 nodes are operational, but the network between them is problematic right now. In this situation a client might make a read request or a write request to N1, N2 or N3. Based on the consistency choices of this client, the reaction of the cluster may differ:
I don't know about Mongo but this is how Cassandra works considering the CAP theorem.
Upvotes: 2
Reputation: 2466
You can achieve "AP" in MongoDB by allowing split brain.
You can make Cassandra "CP" by setting read/writes to "ALL" setting (there are edge cases where QUORUM is not enough).
But, there's a very good article about why calling databases AP/CP is a wrong terminology. There are very strong and solid definition of what is availability and consistency in the context of CAP theorem , and most of the time people do not dive deep enough to understand it, and, by the way most of the databases do not fit in a strict CAP theorem neither as AP or CP.
The link: https://martin.kleppmann.com/2015/05/11/please-stop-calling-databases-cp-or-ap.html
Upvotes: 1
Reputation: 87369
Cassandra uses tunable consistency, that you can control it when writing and/or reading data by using different consistency levels. For example, if you use QUORUM for both writes & reads, then you get strong consistency, although availability may suffer.
P.S. I can't say about Mongo though...
Upvotes: 1