write lock

33 views
Skip to first unread message

Raxit Sheth

unread,
Oct 4, 2012, 3:50:17 AM10/4/12
to mongod...@googlegroups.com
Hi

Using mongodb 2.2.0, Write/Update heavy operations and mongod is
having lock per db (and not lock per collection).

Is it good to have one collection per db in this case? (provided we
are having manageable numbers of collections)

Anyone has tried, if yes any learning in doing so?

Thanks in Adv,
Raxit

Brandon Black

unread,
Oct 5, 2012, 6:49:09 PM10/5/12
to mongod...@googlegroups.com
So it's absolutely possibly for you to structure your data this way. Splitting each of your collections into their own database would definitely get you around DB-level write locks, but there would obviously be an additional cost incurred in disk space pre-allocation.

Additional disadvantages of putting every collection in its own database include:

  • Monitoring: Commands like listDatabases() become significantly slower and services like MMS (10gen's monitoring service) will collect stats less frequently for each database. If you have over 100 databases, MMS won't work at all.
  • Preallocation: Even though this is a background process, it's still an operation that competes with others for resources. As you add more databases, the need for preallocation to run will become more common and as a result demand more resources.
Considering the trade-offs, this approach is probably not too harmful on a small number of write-heavy collections, but its likely not suitable if you're looking at doing this for 100s of collections.
Reply all
Reply to author
Forward
0 new messages