Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Are there any mechanisms to limit the size of a single database on MongoDB 2.6? I found some options like quota, quotaFiles and nssize but am unsure how to use them.

share|improve this question
Are you actually trying to restrict the total size of the database? There are several options to limit individual file sizes, but there is nothing to put a hard limit on how big a database will become. – Neil Lunn Apr 29 '14 at 2:10
Yes, I was thinking something like that. My team and I wanted to give our students MongoDB environments with limited size because of storage limits at our university. – ivica Apr 29 '14 at 8:29
Sorry for spamming, can't edit previous comment. We would like to have around 200 databases (one per user) and each should be limited to lets say 256MB. – ivica Apr 29 '14 at 9:06
up vote 3 down vote accepted

Ok, it was simple :)

I wanted to limit each database to 256MB of space per student. In order to achieve that, I enabled smallfiles in /etc/mongod.conf and ran the mongod process with mongod -f /etc/mongod.conf --quota --quotaFiles 4 which limited the size of the database to 256MB.

smallfiles starts preallocating space with 16MB, then 32MB, 64MB and finally 128MB. Add this up and you get 240MB plus 16MB file for the namespace = 256MB

This however doesn't stop them from creating another database with the same user. Any help on this?

share|improve this answer

Sounds like something for capped collections. Doesn't limit the database itself but does limit the collections?

share|improve this answer

I have the same issue. Mongo does not respect quota. I haven't found the answer, but I found SERVER-5136 . According to this, it is recorded issue but sadly resolution is still not planned.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.