I have read lot of articles on net but still confused why Mongo CP, Cassandra AP, RDBMS CA ? Will explain my understanding and query along with that .
Mongo
Consider a scenario where I have one master ans two slaves. consider
- Write request arrives and goes to master.
- It gets committed on master only but master goes off(crashed) before it is written to slaves
- Till master is re-elected, write requests need to wait and system is not available
- Once the previous node(node crashed in step 2) comes back, writes pending from that node are written back to slaves. This is called eventual consistency.
Per my understanding because of step 3 and 4, Mongo is said to be CP where C stands for eventual consistent. Correct ?
Cassandra
Here there is no master/slave model and every node takes its share write and read request based on shard key.
- Write request arrives to any node(called coordination node).
- Coordination node redirects to one of the node based on shard key
- It gets committed but node goes off(crashed) before it is written to other replication node.
- Again write request with same shard key, now coordinated node redirect it immediately to replica node(replica of crashed node)
- Once the previous node(node crashed in step 3) comes back, writes pending from that node are written back to replica node. So cassandra seems to be eventual consistent too ?
Step 4 explains why cassandra is highly available but step 5 also depicts its eventual consistent. So Per my undsertanding , cassandra provides provides both eventual consistency ans availability. Then why it is said it does not provide Consitency ?