Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replica set and MongoDB, does the option {w: 1} make the system AP in terms of CAP?

In terms of CAP theorem, MongoDB is usually defined as CP by default. In a replica set scenario, is the following correct? The option w is the write concern:

  • { w: 1 }: wait for a confirm only from the primary. If we read from secondary members, the system is eventually consistent and then AP.
  • { w: 3 }: wait for a confirm from three members. If the replica is made of three members, the system is consistent (strong?) and thus CP.
like image 868
gremo Avatar asked Oct 03 '22 15:10

gremo


1 Answers

Looking at Mongodb replication guide it look like, by default all query goes to the primary server. It you want the 'A' you also need to read on secondaries server, this is requiere to be AP. And then you loose the C because the results may be different from one server to another.

The question also look like this one, the answer could be helpful.

like image 169
Galigator Avatar answered Oct 07 '22 19:10

Galigator