MongoDB space usage¶
The following information outlines how ObjectRocket calculates space usage for all MongoDB instances, including determining how much space your MongDB instance is using and an explanation of associated charges.
Calculating space for MongoDB plans¶
On the ObjectRocket MongoDB platform, a plan represents the maximum amount of data you can store on a MongoDB instance without taking any action. When building a MongoDB instance for the first time, you’re required to choose a size in incrementing blocks, such as 5 GB, 20 GB, 50 GB, or others. Because you’ll know exactly how the capacity increases as you grow, this size selection makes it easy to plan out scaling in advance.
If the MongoDB instance is sharded, the plan size is multiplied by the number of shards currently attached to the instance to give you the maximum amount of space available. If the MongoDB instance is a replica set, the plan size is the maximum available storage space.
The following formula shows how to calculate the maximum gigabytes in plan (mgp) for all MongoDB instance types:
By using this formula, a 5 GB sharded instance with 3 shards has a mgp of 15 GB.
All data used for determining space usage is pulled directly from MongoDB by using db.stats() across each individual database on each shard, which differs slightly for WiredTiger or MMAPv1.
If the MongoDB instance is running on WiredTiger, two values are used from the dbStats output, dbStats.storageSize (dss) and dbStats.indexSize (dis). Using these values is necessary because WiredTiger stores data and indexes in separate files.
The following formula shows how space consumed is summarized for WiredTiger per database:
After calculating how much space each database and index use, ObjectRocket uses that information to find out how much space a MongoDB instance is using with the following formula:
MMAPv1 stores data and indexes on the same files, so the only important output is dbStats.fileSize. While MMAPv1 logs both dbStats.storageSize and dbStats.indexSize, this information is only useful in roughly determining the level of fragmentation within the MongoDB instance.
What is not calculated¶
ObjectRocket fully manages MongoDB for you, including the pieces that create storage amplification like replication, journaling, namespace file, and ObjectRocket administrative databases. The following space calculations aren’t necessary:
Oplog size (local)
The admin and config databases
If you have any questions, contact the Support team.