Everywhere I look, I see that MongoDB is CP. But when I dig in I see it is eventually consistent. Is it CP when you use safe=true? If so, does that mean that when I write wi
Mongodb provides consistency and partition tolerance.
In the context of distributed (NoSQL) databases, this means there is always going to be a trade-off between consistency and availability. This is because distributed systems are always necessarily partition tolerant (ie. it simply wouldn’t be a distributed database if it wasn’t partition tolerant.)
Consistency - The system will eventually become consistent. The data will propagate to everywhere it should sooner or later, but the system will continue to receive input and is not checking the consistency of every transaction before it moves onto the next one.
Availability - By default, Mongo DB Client(MongoDB driver), sends all read/write requests to the leader/primary node. It makes the system consistent but not available due to - 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 in that duration.