Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens when mongodb is out of memory?

For example i have db with 20 GB of data and only 2 GB ram,swap is off. Will i be able to find and insert data? How bad perfomance would be?

like image 610
SomeUser Avatar asked Oct 02 '11 19:10

SomeUser


2 Answers

it's best to google this, but many sources say that when your working set outgrows your RAM size the performance will drop significantly.

Sharding might be an interesting option, rather than adding more RAM..

http://www.mongodb.org/display/DOCS/Checking+Server+Memory+Usage

http://highscalability.com/blog/2011/9/13/must-see-5-steps-to-scaling-mongodb-or-any-db-in-8-minutes.html

http://blog.boxedice.com/2010/12/13/mongodb-monitoring-keep-in-it-ram/

http://groups.google.com/group/mongodb-user/browse_thread/thread/37f80ff39258e6f4

Can MongoDB work when size of database larger then RAM?

What does it mean to fit "working set" into RAM for MongoDB?

You might also want to read-up on the 4square outage last year:

http://highscalability.com/blog/2010/10/15/troubles-with-sharding-what-can-we-learn-from-the-foursquare.html

http://groups.google.com/group/mongodb-user/browse_thread/thread/528a94f287e9d77e

http://blog.foursquare.com/2010/10/05/so-that-was-a-bummer/

side-note:

you said "swap is off" ... ? why? You should always have a sufficient swap space on a UNIX system! Swap-size = 1...2-times RAM size is a good idea. Using a fast partition is a good idea. Really bad things happen if your UNIX system runs out of RAM and doesn't have Swap .. processes just die inexplicably.. that is a bad very thing! especially in production. Disk is cheap! add a generous swap partition! :-)

like image 128
Tilo Avatar answered Oct 09 '22 13:10

Tilo


It really depends on the size of your working set.

MongoDB can handle a very large database and still be very fast if your working set is less than your RAM size.

The working set is the set of documents you are working on a time and indexes.

Here is a link which might help you understand this : http://www.colinhowe.co.uk/2011/02/23/mongodb-performance-for-data-bigger-than-memor/

like image 40
kamaradclimber Avatar answered Oct 09 '22 15:10

kamaradclimber