|
The documentation below covers for MongoDB v2.0. v2.0 typically achieves significantly more concurrency in disk activity than v1.8 did. v2.2 will include substantial enhancements with concurrency work being by far the #1 item on the v2.2 road map. mongosFor sharded environments, each mongos process can perform any number of operations concurrently. This results in downstream operations to mongod instances. Execution of operations at each mongod is independent; that is, one mongod does not block another. mongodThe mongod process uses a modified reader/writer lock with dynamic yielding on page faults and long operations. Any number of concurrent read operations are allowed, but a write operation can block all other operations. mongod threads yield their lock (read or write) in two classes of situations:
Write lock acquisition is greedy: a pending write lock acquisition will prevent further read lock acquisitions until fulfilled. Thus yielding by reads can be important. Collection level locking is under development. SERVER-1240. Viewing operations in progressUse db.currentOp() to view operations in progress, and db.killOp() to terminate an operation. Administrative commands and lockingCertain administrative commands can exclusively lock the mongod process for extended periods of time. Specifically, these commands block for long periods:
On a small collection, the lock time may only be a few seconds. On very large collections, take the mongod instance offline so that clients are not effected. For example if the server is part of a replica set, let other members service load while maintenance is in progress. The following commands are fast and will not block the system excessively:
Operations
JavascriptOnly one thread in the mongod process executes Javascript at a time (other database operations are often possible concurrent with this). Note ticket https://jira.mongodb.org/browse/SERVER-4258 will allow multi-threading. Group CommandThe group command takes a read lock and does not allow any other threads to execute JavaScript while it is running. MapReduceThe mapreduce operation is composed of many small events: reads from the input collection, executions of map(), executions of reduce(), writes to the output collection, etc. There is a javascript lock so that only one thread can execute JS code at one point in time. But most JS steps of the MR (e.g. a single map()) are very short and consequently the lock is yielded very often. Note ticket https://jira.mongodb.org/browse/SERVER-4258 will allow multi-threading. There are also several non-JavaScript operations that MapReduce performs that take locks:
The result is that while single-threaded, several MR jobs can be interleaved and appear to run in parallel. |

PLEASE POST QUESTIONS IN THE FORUMS: http://groups.google.com/group/mongodb-user. Post tips and clarifications here.
blog comments powered by Disqus