Solved

MongoDb: WriteConcern

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

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

867 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

15 Experts available now in Live!

Get 1:1 Help Now