From the doc , it said
"For best performance, the majority of your active set should fit in RAM."
So for example, my db.stats()
give me
{
"db" : "mydb",
"collections" : 16,
"objects" : 21452,
"avgObjSize" : 768.0516501957859,
"dataSize" : 16476244,
"storageSize" : 25385984,
"numExtents" : 43,
"indexes" : 70,
"indexSize" : 15450112,
"fileSize" : 469762048,
"ok" : 1
}
Which value is the working set size
?
The SO question/answer linked by quanta in the comments is correct, the "Working set" is basically the amount of data AND indexes that will be active/in use by your system.
You cannot tell from
db.stats()
what that will be unless you think that you will need to have the entire set of data and the entire index in RAM. That is, you can work out the maximum working set for that database, but not the actual active working set. The maximum is the sum of:In your case, that maximum would be approximately 30.45 MiB given the output you pasted.
For tracking the actual memory usage I would recommend a combination of the figures from
db.stats()
and the memory graphs (resident memory in particular) available in the free monitoring tool - MMS.Update (04/08/2013):
Version 2.4 added a Working Set Size Estimator to the serverStatus command - it is just an estimate, but it can be used as a guide and to check if the other figures and estimates above make sense for you MongoDB instance.
Update (September 2016):
Three years on from my original answer and things are a great deal more complicated - generally getting the size of your data and your indexes is stil a good starting point. But, figuring things out in MongoDB will now depend on what storage engine you are using. Additionally, Version 3.0 removed the Working Set estimator linked above for MMAP as part of the collection level locking work (see SERVER-13783). There is now (for example) the cache statistics for the
WiredTiger
engine as a replacement assuming you have made the jump to the new engine. ForMMAP
, the general recommendation is to look at the page faults metric as a proxy for whether your data is fitting into memory or not.