Concurrency Issues

176 views
Skip to first unread message

ideabank

unread,
Nov 8, 2011, 7:01:17 AM11/8/11
to mongodb-user
Hi,

I have application that keeps adding data to DB ( 30-45 secs out of 1
min ) and at the same time reading the data on request ( ISPs
reporting )

In MySQL, Myisam Engine does table level locking while inserts,
Mongodb is different in this way ?

Which one has better Locking mechanism so that Locking remains
transparent to end user in high-end read / write application.

Many thanks

Mike O'Brien

unread,
Nov 8, 2011, 11:58:46 AM11/8/11
to mongodb-user
Hi,Mongo has a global write/read lock - Reads can happen concurrently,
but only one write executes at a time, and some write operations will
intelligently yield.However, mongo updates are very fast especially
when using in-place modifiers. Your best bet in getting an idea of how
the two compare for your application is probably to writing a simple
test/benchmark to simulate the type of data + loads you are expecting
- you can use mongostat to check lock %.
For additional performance, you could also separate read and write
queries by setting up replication, and sending your read queries to
the slave, and sending all writes to the master. Also note that
collection-level will be coming soon (https://jira.mongodb.org/browse/
SERVER-1240) which will further reduce chances of lock contention.
Hope this helps,-Mike

ideabank

unread,
Nov 10, 2011, 8:58:35 AM11/10/11
to mongodb-user
Thanks Mike for detailed reply,

In MYSQL, in InnoDB I assume there is no Table Level Locking unlike in
MYSIAM
Can we force mongo to behave like innodb for Inserts and Updates ?

thanks again

Sam Millman

unread,
Nov 10, 2011, 9:01:03 AM11/10/11
to mongod...@googlegroups.com
I suppose you could implement a lock queue yourself and bind it into your app but:


10gen make some good points in the first paragraph, maybe you should work around mongos lock instead of trying to overcome it?

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


Martin Skøtt

unread,
Nov 10, 2011, 8:48:36 PM11/10/11
to mongod...@googlegroups.com
On Thu, Nov 10, 2011 at 15:01, Sam Millman <sam.m...@gmail.com> wrote:
I suppose you could implement a lock queue yourself and bind it into your app but:


10gen make some good points in the first paragraph, maybe you should work around mongos lock instead of trying to overcome it?

Slightly off-topic, but in my experience using MongoDB together with Node.JS and the mongo-native driver it can be a really good idea to use callbacks instead of trying to force your code into a more traditional procedural style.

I discovered this when I experienced concurrency issues when "upserting" a lot of data. Callbacks + the atomic operators not only fixed the issues, but also made the code more readable :)

--
Venlig hilsen/Kind regards
Martin Skøtt
Freelance software developer

Reply all
Reply to author
Forward
0 new messages