David - Musings of an SRE

Mongodb caveats; you need swap space

So I was helping out a friend figure out why his server keeps crashing and timing out.

Having moved his mongodb query code out into its own controller and setup an onload AJAX call, I subsequently started to look deep into the mongodb logs.

I noticed this appearing:

Tue Dec 10 15:20:14.043 [conn3] getmore bleah.data query: { $where: "

Doing a google, I came across this article. Apparently, mongodb dies when it runs out of memory.

Pretty straightforward right. Mongodb runs on memory for a while until it writes to disk.

Rudimentary stuff but it somehow went right under my nose.

True enough, when I looked at “free -m”, the instance doesn’t have any swap memory.

So this is a reminder to folks who have problems with mongodb. Remember your swap.