I was trying to figure out why the site hosted on a VPS with 2GB RAM started showing pages in ~2 seconds while on localhost it only takes about 200ms at worst. I want to note that IIRC, it didn’t happen in the past, and there is no difference in load or visitor count. Top shows 0% CPU usage most of the time, 77M RAM free, 4M swap used.
I have profiled a slow request and discovered that 87% of the time is spent calling MongoCursor::getNext. The mongodump of the used DB is 800MB, so the memory shouldn’t be a problem. The OS is 64bit Ubuntu 11.
What steps do I take to fix this problem?
Turned out to be caused by old mongo version – on the VPS it was 1.8.* and on my local box – 2.0.4. After I upgraded mongo and
mongorestored the data I had to rundb.repairDatabase()since some data wasn’t fetching witherror: { "$err" : "assertion db/key.cpp:409" }. Now everything is back to normal.