Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB constantly high cpu usage

Tags:

According to docker container statistics, my mongo database consumes constantly between 250 and 350% cpu. That's pretty impressive since it's a single core system :P

The sad part is that this is my production instance and much more sad is that it has to live until the next prod-backup and thats 3.5 more hours to go.

I tried to do a mongotop but it tells me 0ms stats for all shown collections. Can I do anything else to figure out what's going on?

PS: The db is up for 9 weeks and didn't cause problems.

like image 281
alsdkjasdlkja Avatar asked Jan 22 '16 16:01

alsdkjasdlkja


1 Answers

There is a function called db.currentOp() which lists the currently running queries with very detailed information, it also includes the duration they have been running (secs_running).

You can then use the currentOp.opid with db.killOp() to kill that query/operation.

If db.currentOp() doesn't return any results, because there is no query which went havoc, then there's also db.setProfilingLevel() which will enable profiling by storing queries into the "local" database. Here's a "Tutorial" which is from the "M102: MongoDB for DBAs" Course.

Further information can also be found in this detailed article "Troubleshooting MongoDB 100% CPU load and slow queries" from Igor Khomenko.

like image 154
Daniel F Avatar answered Sep 20 '22 18:09

Daniel F