Solved

MongoDb: WriteConcern

Posted on 2014-02-21
3
297 Views
Last Modified: 2016-02-10
Hi there,

I am using mongodb client for java and I want it to be efficient.

Which "WriteConcern" is most efficient to be used?

Any help is greatly appreciated. I have done programming but it is my first time using mongodb.

Thanks,
Zizi
0
Comment
Question by:zizi21
3 Comments
 
LVL 26

Accepted Solution

by:
dpearson earned 300 total points
ID: 39879604
I've not personally used Mongo but I understand its design.  As you raise the strength (level) of WriteConcern you will get less efficiency but more guarantees that the write has completed.

For low level settings like "Unacknowledged" you'll get a really fast response, but there's no guarantee that the data has been reliably written.  So if you had a server crash you might not be able to recover that write.  This may or may not be OK.

Up at the high end like "Replica Acknowledged" your writes will wait until Mongo has successfully heard back from other servers indicating that the write has propagated.  You can be sure that data won't be lost even after a server crash here.  But it will be significantly slower as you are waiting for those replicating servers to receive the data and respond back.

Hope that helps,

Doug
0
 
LVL 11

Assisted Solution

by:anilallewar
anilallewar earned 200 total points
ID: 39879865
It depends on what your use case is :)

The default write concern is acknowledged which means that the server was able to successfully write your entry and there is no error but it is not going to wait for journaling or replication confirmation.

IMHO this is the most efficient writeconcern that would also give you enough consistency so that you know that your writes made their way to the primary node.

As Doug said if you really concerned about the speed of writes, you can go with un-acknowleged writes but you would not know if the last write failed.
0
 
LVL 27

Expert Comment

by:Nopius
ID: 40090053
Hi, zizi21.

I know, it's too late for comments, but you may read this blog post with benchmark results and good recommendations in write-mostly scenario.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question