Set MongoDB Database Quota (SIZE)

I want to allow my hosting sites to use MongoDB, however, since they are all on the same VPS server, I can get mongo to create databases and bind them to users, but I can't seem to limit the size of the database β€” just the size of the collection. What can be changed.

Dispatched as an administrator to limit the size of the database.

+6
source share
2 answers

MongoDB allocates database fragments starting at 64 MB (dbname.0), followed by 128 MB (.1), 256, etc. up to 2 GB, then each file exits 2 GB from it.

If you use --smallfiles in the --smallfiles command-line options, file allocation starts at 16 MB instead of 64 MB, and the maximum value is 512 MB instead of 2 GB.

Combine this with --quotaFiles 1 , and your database cannot grow in one file, or ... 16 MB. I always use --quotaFiles in conjunction with --quota in help documents.

+12
source

I do not believe that this can be done with MongoDB. If at all possible, you might want to create volumes on your server with the quota set and deploy multiple instances of mongod

However, you should keep in mind that MongoDB is trying to store as much data as possible in memory. This can cause performance problems for clients when their data is replaced on disk in exchange for other people's data.

-1
source

Source: https://habr.com/ru/post/911157/


All Articles