|Concurrency Issues||ideabank||11/8/11 4:01 AM|
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
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.
|Re: Concurrency Issues||Mike O'Brien||11/8/11 8:58 AM|
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
|Re: Concurrency Issues||ideabank||11/10/11 5:58 AM|
Thanks Mike for detailed reply,
In MYSQL, in InnoDB I assume there is no Table Level Locking unlike in
Can we force mongo to behave like innodb for Inserts and Updates ?
|Re: [mongodb-user] Re: Concurrency Issues||Sammaye||11/10/11 6:01 AM|
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?
|Re: [mongodb-user] Re: Concurrency Issues||Martin Skøtt||11/10/11 5:48 PM|
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
Freelance software developer