首页 > 解决方案 > Track mb used per each user

问题描述

I'm trying to figure out a way to implement a tracking system based on how many megabytes a user has used for a MongoDB database.

Say I have a email field value for each document associated with a user (myemail@example.com). A user can append new documents to multiple collections in the database whenever he / she wants through a web-application, but is not allowed to exceed 100MB in total storage.

Basically I want to track when all associated documents for each email has exceeded 100MB, respectively.

How can I with high performance and accuracy track this?

Thanks!

标签: mongodb

解决方案


您可以使用$bsonSize来计算一组文档占用了多少空间。

MongoDB 曾经有一个带有 MMAP 的配额系统,但这不是 Wired Tiger 提供的功能。


推荐阅读