colocating with mongo?

30 views
Skip to first unread message

Rob Young

unread,
Jan 18, 2013, 5:41:03 PM1/18/13
to mongod...@googlegroups.com
If I co-locate a web service on the same box with a mongo primary, can my service grab as much RAM as it needs, and let mongo (naturally) grab the rest? I'd like to more or less divvy up the RAM 50/50 between the two.

Are there any other gotchas that make that a bad idea?

(I think the eventual production deployment will be more traditional, but I'm thinking about deployment options.)

Philipp Knobel

unread,
Jan 23, 2013, 9:29:30 AM1/23/13
to mongod...@googlegroups.com
No that will not work. As mongodb has no memory handling, it's fully upto your OS for the memory distribution. MongoDB will allocate as much memory as available if it's needed (if your active dataset+indexes is half of your RAM it will work though). Don't know if something exists on the OS level for that. It could work if your web service is very busy and accesses all its memory pages frequently so that the OS isn't swapping them out. But I really wouldn't count on this.

Sam Millman

unread,
Jan 23, 2013, 10:57:27 AM1/23/13
to mongod...@googlegroups.com
Though you can use the OS' own memory management tools to actually acheive this, at a price unless you know what your doing.

For example you can ulimit the mongodbs user to 50% of the ram allowing your web service to eat the rest. Providing your working set allows it this could be perfectly normal.


--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
 
 
 

Sam Millman

unread,
Jan 23, 2013, 10:58:25 AM1/23/13
to mongod...@googlegroups.com
Note: ulimit is Linux (and I think Unix too), I am unsure of the edition for Windows.

gregor

unread,
Jan 25, 2013, 12:02:32 PM1/25/13
to mongod...@googlegroups.com
Yes you can do that - mongo memory maps the data files - so when the OS has spare RAM, the data in those files will be held in memory, when the OS needs RAM it will take it back from mongo - the data in RAM is backed by file anyway. So when your webserver needs RAM, the OS will allocate it. For this reason, there is nothing to be concerned about when you see mongo taking large amounts of RAM - the OS can take it back when it needs it. *However* performance will suffer if mongo doesn't have enough RAM available - if your webserver is taking too much. You want your working set to be held in RAM. Wouldn't recommend the 50/50 approach. 

Rob Young

unread,
Jan 25, 2013, 12:23:45 PM1/25/13
to mongod...@googlegroups.com
Excellent, thank you for the input! Much appreciated.

I appreciate the advice, and it's also reassuring that I was thinking about it the right way, with the OS itself grabbing the unused RAM as its available.

As for the app -- we'll see what we end up doing. My hope is that we can limit the dataset so that the whole thing will fit in RAM (the data set === the working set) because I think the whole thing will be "in play". But we'll see what works best.

gregor

unread,
Jan 25, 2013, 5:33:54 PM1/25/13
to mongod...@googlegroups.com
MMS http://mms.10gen.com/help/ is a great way of monitoring your deployment for page faults - where your working set is larger than RAM altough there are a bunch of other tools
Reply all
Reply to author
Forward
0 new messages