Keep an eye on your MongoDB

I don’t use MongoDB that often, but sometimes it is the perfect tool for a job.

I have one database with about 2 million documents in the main collection. We needed to rebuild and reprocess the documents in the collection recently – essentially emptying the collection and letting it rebuild naturally as new data came in.

After a while I started to notice some severe performance issues on the server as the collection grew. Mongo was consuming vast amounts of CPU. Eventually the penny dropped. After the update, the new indexes had not been created.

As soon as the indexes were added, the amount of resource used by Mongo dropped back to an almost irrelevant level. I am astonished as the performance difference they made.

Not a mistake to make again!