2

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.

3
  • 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
    Commented Apr 29, 2014 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
    Commented Apr 29, 2014 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
    Commented Apr 29, 2014 at 9:06

3 Answers 3

3

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?

2

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

http://blog.mongodb.org/post/116405435/capped-collections

0
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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