MongoDB Write Concern: 3 Must-Know Caveats

Article posted on : link to source

‘Write concern’ in MongoDB describes the level of write acknowledgment you can expect from it. It’s a rather important setting to remember in your write operations and its behavior is useful to understand, especially in distributed MongoDB deployments (i.e. replica sets and sharded clusters). In this post, we discuss 3 gotchas when using MongoDB write concern.

Read the original article: MongoDB Write Concern: 3 Must-Know Caveats

MongoDB Write Concern

MongoDB’s documentation defines write concern as “the level of acknowledgment requested from MongoDB for write operations to a standalone mongod or to replica sets or to sharded clusters.”

Simply put, a write concern is an indication of ‘durability’ passed along with write operations to MongoDB. To clarify, let us look at the syntax:

{ w: <value>, j: <boolean>, wtimeout: <number> }
Where*,
w can be an integer | “majority” | , it represents the number of members that must acknowledge the write. Default value is 1.
j Requests that a write be acknowledged after it is written to the on-disk journal as opposed to just the system memory. Unspecified by default.
wtimeout specifies timeout for the applying the write concern. Unspecified by default.

* You can find the detailed syntax in the Write Concern Specification documentation.

* Learn more about the different …

Read More on Datafloq