midMongoDB
Explain Write Concern in MongoDB.
Updated May 1, 2026
Short answer
Write concern describes the level of acknowledgment requested from MongoDB for write operations.
Deep explanation
Options include 'w: 1' (primary ack), 'w: majority' (majority of replica set), and 'j: true' (on-disk journal ack).
Real-world example
Ensuring critical financial transactions are committed to a majority of nodes.
Common mistakes
- Using 'w: majority' for low-priority logs, which increases latency unnecessarily.
Follow-up questions
- What is 'wtimeout'?