Solved

MongoDb: WriteConcern

Posted on 2014-02-21
3
286 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now