CAP THEOREM Flashcards

1
Q

What is CAP Theorem?

A

CAP theorem states that a distributed system cannot provide all three of the following desirable properties: consistency, availability, partition tolerance.

Any distributed system needs to pick two out of the three properties. The three options are CA, CP, and AP. However, CA is not really a coherent option, as a system that is not partition-tolerant will be forced to give up either Consistency or Availability in the case of a network partition. Therefore, the theorem can really be stated as: In the presence of a network partition, a distributed system must choose either Consistency or Availability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is consistency?

A

All nodes see the same data at the same time. This means users can read or write from/to any node in the system and will receive the same data. It is equivalent to having a single up-to-date copy of the data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is availability?

A

Availability means every request received by a non-failing node in the system must result in a response.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is partition tolerance?

A

A partition is a communication break (or a network failure) between any two nodes in the system, i.e., both nodes are up but cannot communicate with each other

A partition-tolerant system continues to operate even if there are partitions in the system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which aspect of CAP did ACID databases choose?

A

Consistency. Software like mySQL, Oracle, and more refuse to respond until it can check with its peers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In CAP, what did BASE databases choose?

A

BASE databases (Basically available, soft-state, eventually consistent), like Cassandra and Mongo, chose availability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is PACELC theorem?

A

P = Partition: What happens when there’s a network partition?

A = Availability

C = Consistency

E = Else (when there is no partition)

L = Latency

C = Consistency

In other words, in the presence of a network partition, a system can choose either availabilty or consistency. In the absence of a partition (all nodes can communicate with one another), a system can choose latency or consistency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Give an example of PACELC in action.

A

Dynamo and Cassandra are PA/EL systems: They choose availability over consistency when a partition occurs; otherwise, they choose lower latency.

BigTable and HBase are PC/EC systems: They will always choose consistency, giving up availability and lower latency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Give an example with MognoDB and PACELC.

A

MongoDB can be considered PA/EC

MongoDB works in a primary/secondaries configuration. In the default configuration, all writes and reads are performed on the primary. As all replication is done asynchronously (from primary to secondaries), when there is a network partition in which primary is lost or becomes isolated on the minority side, there is a chance of losing data that is unreplicated to secondaries, hence there is a loss of consistency during partitions. Therefore it can be concluded that in the case of a network partition, MongoDB chooses availability, but otherwise guarantees consistency. Alternately, when MongoDB is configured to write on majority replicas and read from the primary, it could be categorized as PC/EC.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the difference between a network partition and a database partition?

A

A network partition is a failure scenario in a distributed system where different parts of the network can’t communicate with each other due to a disruption.

Database partitioning is a design strategy to split a large database into smaller, more manageable chunks called partitions or shards.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly