For most replica sets, w: "majority" is the durability-oriented starting point: it waits for acknowledgement from a calculated majority of voting data-bearing members. With MongoDB’s default writeConcernMajorityJournalDefault: true, that acknowledgement also waits for writes to be journaled to disk. The trade-off is potentially higher latency and failure to acknowledge promptly if enough members are unavailable or lagging. Check your topology and configured defaults before relying on that behavior.
Use w: 1 only when the application can tolerate an acknowledged write rolling back if the primary fails before replication. Add wtimeout when you need to bound waiting for acknowledgement, but treat a timeout as uncertain completion—not proof that MongoDB cancelled the write.
As an Amazon Associate I earn from qualifying purchases.
What MongoDB write concern controls
MongoDB defines write concern as “the level of acknowledgment requested from MongoDB for write operations to a standalone mongod, replica sets, or sharded clusters.” It controls when a write operation returns acknowledgement; it does not, by itself, ensure a client can reach a primary, that a later read sees the newest data, or that the service meets an overall availability target. See MongoDB’s Write Concern documentation.
A write concern document can specify w, j, and wtimeout. They govern different parts of the acknowledgement requirement:
#1 Best Overall
wsets the acknowledgement threshold: a number of members, a tag-based requirement, or"majority".jrequests acknowledgement that the relevant writes have been committed to the journal.wtimeoutsets a maximum wait, in milliseconds, for the requested write concern to be satisfied.
Choosing an acknowledgement level
| Setting | What MongoDB waits for | Durability and availability trade-off |
|---|---|---|
w: 1 |
The primary applies the write. | Lower acknowledgement wait, but the write can roll back if the primary steps down before replication. |
w: "majority" |
A calculated majority of voting data-bearing members acknowledges the write. | With the default majority-journal setting, acknowledgement waits for journal durability. It reduces rollback risk, but can add latency or fail to arrive promptly when members are unavailable or lagging. |
Numeric w: n |
The primary and enough other members to meet the specified member count. | A higher threshold can add latency or be impossible if too few data-bearing members are available. Without journaling, a numeric threshold greater than the calculated majority can be acknowledged before majority durability under the default behavior. |
w: "majority", wtimeout: N |
Majority acknowledgement, with waiting bounded by N milliseconds. |
If the threshold is not met in time, MongoDB returns a write concern error. The timeout does not undo an operation already applied on the primary. |
w: 1 is not a promise that the write exists on multiple nodes or is immune to rollback. In contrast, w: "majority" requests a voting majority; it is not interchangeable with an arbitrary numeric w. MongoDB’s replica-set write concern guide explains these acknowledgement and failover trade-offs.
How journaling changes durability
For majority writes where j is omitted, the cluster-wide writeConcernMajorityJournalDefault setting controls whether journal persistence is required. It defaults to true, so majority acknowledgement normally waits for writes to be journaled to disk. If it is set to false, majority writes can be vulnerable to rollback after a transient loss of a majority of nodes. Verify this setting rather than assuming all clusters have the same behavior. MongoDB documents the setting and journal semantics in its Write Concern manual.
For numeric write concern, j: true requests journal acknowledgement from the eligible members counted toward the requested threshold. Explicitly requesting j: true on a server running without journaling results in an error. Journal acknowledgement improves persistence protection, but j: true alone does not provide the replication protection of majority acknowledgement: a primary can still fail before the write has been replicated.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Set a timeout without treating it as cancellation
wtimeout bounds the time MongoDB waits for the requested write concern. MongoDB’s replica-set documentation illustrates wtimeout: 5000 (5,000 milliseconds) in an example; that is an example value, not a universal recommendation. Choose a bound that fits the application’s latency budget and retry strategy.
Rank #3
If the timeout expires before the requested threshold is satisfied, the operation returns a write concern error. MongoDB does not undo modifications already made on the primary. Your application may therefore face an uncertain outcome: the write may have taken effect even though the requested acknowledgement was not returned. Design retries and idempotency around that possibility. The timeout applies to waiting for write concern, not to the primary’s execution time.
Configure the concern for your topology
MongoDB’s implicit default is commonly w: "majority", but it is not safe to assume that every deployment uses it. With arbiters, if the number of data-bearing voting members is not greater than the voting majority, the implicit default is w: 1. A configured cluster-wide default can also affect behavior. Inspect the actual topology and defaults using MongoDB’s default read and write concern documentation.
Rank #4
Topology also affects whether a requested concern is practical. In a three-member primary-secondary-arbiter deployment, for example, a lagging or unavailable secondary can make majority write concern a performance problem. Evaluate the failure modes you need to tolerate and the data-bearing members that can acknowledge writes; a voting majority is not a substitute for having adequate data-bearing capacity.
MongoDB’s development checklist recommends at least three data-bearing voting members for replica-set-wide data durability, alongside majority write concern. Treat that as general guidance, not a replacement for distributing members across appropriate failure domains or sizing the deployment for its workload.
Best Value
Use write concern at the right scope
Individual writes
For an insert or other write outside a transaction, pass a write concern appropriate to the operation and the deployment. MongoDB’s replica-set example uses w: "majority" with wtimeout: 5000 for an insert:
db.orders.insertOne(
{ _id: 1001, status: "queued" },
{ writeConcern: { w: "majority", wtimeout: 5000 } }
)
This demonstrates syntax only. The 5,000-millisecond bound is MongoDB’s documented example, not a recommended setting for every application.
Multi-document transactions
Set write concern at the transaction level, not on individual operations inside a multi-document transaction. If you use majority read concern inside a transaction, its guarantee applies only when the transaction commits with majority write concern. See the MongoDB documentation on write concern and read concern.
Free tools Windows power users keep installed
One-click scans. No signup required.
Coordinate writes with reads and causal consistency
A write acknowledgement and the visibility of data to a subsequent read are distinct concerns. A read from one node may not reflect the newest version of the system’s data. Majority read concern returns data acknowledged by a majority and guaranteed not to roll back under its documented conditions; in a transaction, that read guarantee requires majority commit. Consult MongoDB’s Read Concern manual when choosing how clients read after writes.
For the documented causal guarantees in causally consistent sessions, use majority read concern and majority write concern for the associated operations. That pairing supports causal ordering and read-your-own-writes behavior under MongoDB’s documented conditions; write concern alone does not establish those read guarantees. See Causal Consistency and Read and Write Concerns.
Quick Recap
A practical selection checklist
- Choose
w: "majority"when rollback resistance across primary failover is more important than the lowest possible acknowledgement latency. - Choose
w: 1only when the application accepts the rollback risk of primary-only acknowledgement. - Use numeric
wor tag-based acknowledgement when the required member count or placement is intentional; do not assume a number means majority. - Verify
writeConcernMajorityJournalDefault, topology, arbiters, and cluster-wide defaults before relying on implicit behavior. - Add a workload-appropriate
wtimeoutonly with application handling for write concern errors and uncertain completion. - For transactions, configure concern at transaction scope; pair majority write and read concerns where the documented causal or read guarantees are required.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




