Question

In: Computer Science

The CAP theorem says a database cannot have all three of these features: partition (fault tolerance)...

The CAP theorem says a database cannot have all three of these features: partition (fault tolerance) and consistency and availability. We know that both MongoDB database system and Cassandra database system provide fault tolerance (partition). So how do they handle consistency and availability in their different ways?

  1. How does the MongoDB database system handle both consistency and availability in spite of what is stated by the CAP theorem?
  2. How does the Cassandra database system handle both consistency and availability in spite of what is stated by the CAP theorem?
  3. What are the key differences between how the two database systems handle consistency and availability?

Solutions

Expert Solution

Cassandra database:

Cassandra maintains tunable consistency. When performing a read or write operation a database client can specify a consistency level. The consistency level refers to the number of replicas that need to respond for a read or write operation to be considered complete. For reading non-critical data (the number of “likes” on a social media post, for example), it’s probably not essential to have the very latest data. You can set the consistency level to ONE and Cassandra will simply retrieve a value from the closest replica. If I’m concerned about accuracy, however, I can specify a higher consistency level, like TWO, THREE, or QUORUM. If a QUORUM (essentially a majority) of replicas reply, and if the data was written with similarly strong consistency, users can be confident that they have the latest data. If there are inconsistencies between replicas when data is read, Cassandra will internally manage a process to ensure that replicas are synchronized and contain the most recent data.

The larger the consistency level, the availability of the system will decrease.
Example: Say we have set Consistency level to THREE, for a Cassandra DB whose replication factor is 3.
If one of the replicas disconnects from the cluster, both read and write will start to fail, making the system Unavailable for both read and write. In Summary, Cassandra is always available but once we start tweaking it to make more consistent, we lose availability.

MongoDB database:

By default, Mongo DB Client(MongoDB driver), sends all read/write requests to the leader/primary node.

Again this default behavior allows Mongo DB to be a consistent system but not available due to the below reasons:

  1. If a leader disconnects from the cluster, it takes a few seconds to elect a new leader. So, making it unavailable for writes and reads.
  2. A client can always disconnect from the leader due to network partition even if both client and leader node is running fine. Hence making it unavailable.

So, if we use MongoDB client with its default behavior, MongoDB behaves as a Consistent system and not Available.

We could simply configure read-preference mode in MongoDB client to read from any secondary nodes.
But, by doing so we are breaking consistency. Now, a write to primary/leader can be successful but, secondary’s might not have updated the latest data from primary due to any reason.
So, with this setup, you get high availability for reads but lose consistency and inturn you get eventual consistency.


Related Solutions

Select all the features Jupiter and Saturn have in common.
Select all the features Jupiter and Saturn have in common.
Sorry, this is all the info I have on this problem, I have. If you cannot...
Sorry, this is all the info I have on this problem, I have. If you cannot do it please cancel/refund the question so we both can save time :) 5. A type of order that becomes a market order when a round lot trades at or through a particular price is called a a. market order b. limit order c. stop order d. none of the above 6. A customer's initial transaction in a margin account is the purchase of...
Describe the general structure of a virus, indicating what features all viruses have and what features...
Describe the general structure of a virus, indicating what features all viruses have and what features are unique to certain viruses. What controls the tropism of a virus?
1. These three terms all refer to the same part of a database: True or False...
1. These three terms all refer to the same part of a database: True or False Instance Row Field 2. When compared to File Processing systems, select each of the following that are advantages of a database system. Note: there may be more than one right answer. Group of answer choices; A. Shorter development times. B. If the data structure changes, a program may not need to be changed. C. The data does not need to be duplicated. D. There...
suppose given the three pairwise independent events, all three of which cannot simultaneously occur. Assuming that...
suppose given the three pairwise independent events, all three of which cannot simultaneously occur. Assuming that they all have the same probability x , determine the largest possible value of x.
suppose given the three pairwise independent events, all three of which cannot simultaneously occur. Assuming that...
suppose given the three pairwise independent events, all three of which cannot simultaneously occur. Assuming that they all have the same probability x , determine the largest possible value of x. plz give the steps thx
If one? three-digit number? (0 cannot be a left? digit) is chosen at random from all...
If one? three-digit number? (0 cannot be a left? digit) is chosen at random from all those that can be made from the following set of? digits, find the probability that the one chosen is not a multiple of 5 . (0,1,2,3,4,5,6)
Mr Boggs is a nurse manager for a busy ICU. He cannot cover all three shifts...
Mr Boggs is a nurse manager for a busy ICU. He cannot cover all three shifts with the nurses he has available. what are the values, virtues, or obligations at stake in this case?
a. What is the difference between atoms and molecules? b. List all elements that cannot have...
a. What is the difference between atoms and molecules? b. List all elements that cannot have an "expanded octet."
In our Eco 207 class, we have a policy that says we take the best three...
In our Eco 207 class, we have a policy that says we take the best three out of four of your exam grades and count then toward your overall course grade. In other words, we drop the lowest score. (below, assume that the professor’s goals are to have the students work hard all semester long, and obtain good grades) a. What part of this policy provides a positive incentive to do well? b. What is problematic about this policy from...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT