MongoDB constantly high CPU utilization

According to docker container statistics, my mongo database constantly consumes between 250 and 350% of the processor. This is very impressive as it is one basic system: P

The sad part is that this is my production copy, and all the more sad that it has to live until the next prod backup, and that’s another 3.5 hours.

I tried to make mongotop, but it tells me 0ms statistics for all the collections presented. Can I do anything else to find out what is happening?

PS: db works for 9 weeks and does not cause problems.

+15
mongodb
source share
2 answers

There is a function db.currentOp (), which lists current requests with very detailed information, and also includes the duration of their execution ( secs_running ).

Then you can use currentOp.opid with db.killOp () to kill this request / operation.

If db.currentOp() does not return any results because there is no query that led to chaos, then there is also db.setProfilingLevel (), which will enable profiling by storing queries in a "local" database. Here is the Tutorial from the course M102: MongoDB for Database Administrators .

Further information can be found in this detailed blog post by Igor Khomenko.

+20
source share

The first and more important opinion that you need to do is check your requests, for example, in my case I have the same problem, and when I check my tail -f /var/log/mongodb/mongod.log logs (you can configure these logs are /etc/mongod.conf). I only saw simple queries like db.brands.find ({"field": "value"}), but I check my indexes in the brands collections, and this field in queries is not an index (db.brands.getIndexes ()) the only thing I did was index this field db.brands.ensureIndex({name:1},{unique:true}) , of course, make sure your field is unique, because in this example I put as unique . After that, my processor changed from 100% to 20%.

Therefore, I am not saying that this is your problem, but maybe check your queries before you think.

+17
source share

All Articles