Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it ideal that MongoDB is using 150 MB memory?

This is the first project by me which is using MongoDB.

I have hosted it on a linode (a VPS which uses XEN) and I'm checking memory usage with "top".

The mongod process seem to use around 150 MB of memory. There were no connections to it when I checked. I use RockMongo to administer it. My main database stats are -

Size - 464m 
Storage Size - 83.99m
Data Size - 66.4m
Index Size - 49.33m
Collections - 5
Objects - 584850

A lot of queries happen when the cron job is running, around 75 per minute or even more. But, as I said earlier, when I checked the memory usage, there were no connections.

Output of db.serverStatus();

Note - I had restarted mongod before running db.serverStatus(); and the memory usage was 40 MB.

{
   "retval": {
     "version": "1.6.5",
     "uptime": 790,
     "uptimeEstimate": 783,
     "localTime": "Mon, 07 Feb 2011 00: 51: 04 -0500",
     "globalLock": {
       "totalTime": 790027671,
       "lockTime": 376381,
       "ratio": 0.00047641495838188,
       "currentQueue": {
         "total": 0,
         "readers": 0,
         "writers": 0
      }
    },
     "mem": {
       "bits": 64,
       "resident": 38,
       "virtual": 957,
       "supported": true,
       "mapped": 288
    },
     "connections": {
       "current": 2,
       "available": 9598
    },
     "extra_info": {
       "note": "fields vary by platform",
       "heap_usage_bytes": 152448,
       "page_faults": 0
    },
     "indexCounters": {
       "btree": {
         "accesses": 1,
         "hits": 1,
         "misses": 0,
         "resets": 0,
         "missRatio": 0
      }
    },
     "backgroundFlushing": {
       "flushes": 13,
       "total_ms": 1,
       "average_ms": 0.076923076923077,
       "last_ms": 0,
       "last_finished": "Mon, 07 Feb 2011 00: 50: 54 -0500"
    },
     "cursors": {
       "totalOpen": 0,
       "clientCursors_size": 0,
       "timedOut": 0
    },
     "opcounters": {
       "insert": 0,
       "query": 57,
       "update": 0,
       "delete": 0,
       "getmore": 0,
       "command": 46
    },
     "asserts": {
       "regular": 0,
       "warning": 0,
       "msg": 0,
       "user": 0,
       "rollovers": 0
    },
     "ok": 1
  },
   "ok": 1
}

A friend of mine runs his WordPress blog on a linode with same amount of ram (1024 MB). His MySQL usage show mere 20.48 and approx. 12 users are like "always-surfing" (as in always-on) on his site.

This makes me feel MongoDB isn't a nice choice for me and I should have sticked to MySQL!

Thank you, all.

like image 307
kapeels Avatar asked Feb 07 '11 05:02

kapeels


People also ask

How much memory do I need for MongoDB?

MongoDB requires approximately 1 GB of RAM per 100.000 assets. If the system has to start swapping memory to disk, this will have a severely negative impact on performance and should be avoided.

Does MongoDB use a lot of memory?

And by default, MongoDB will reserve 50% of the available memory – 1 GB for the WiredTiger cache or 256 MB whichever is greater. For example, a system with 16 GB of RAM, would have a WiredTiger cache size of 7.5 GB. The size of this cache is important to ensure WiredTiger is performant.

How much data we can store in MongoDB?

The maximum size an individual document can be in MongoDB is 16MB with a nested depth of 100 levels. Edit: There is no max size for an individual MongoDB database.

How can you check the amount of mapped memory that MongoDB is using?

You can inspect mem. mapped to check the amount of mapped memory that mongod is using. If this value is greater than the amount of system memory, some operations will require a page faults to read data from disk.


1 Answers

"Using" that much memory isn't as bad as it seems ... MongoDB will (at least seem to) use up a lot of available memory, but it leaves it up to the OS's VMM to tell it to release the memory when need. (see Caching in the MongoDB docs.)

For the most part it's "using" that memory for cache, which dramatically speeds things up.

You should be able to release any and all memory by restarting MongoDB.

However, to some extent MongoDB isn't really actively "using" the memory ... read on for a lot more details in this anwser ..

How to release the caching which is used by Mongodb?

like image 191
Justin Jenkins Avatar answered Oct 27 '22 00:10

Justin Jenkins