Update: As requested I am using 18.04.2-Ubuntu and about the MongoDB
I have a virtual machine running several Node JS projects and a local instance of Mongo DB. The virtual Machine has only 2 GB of RAM. And I'm monitoring the database with the free monitoring provided by mongo DB
The problem occurs randomly, the CPU usage by Mongo DB goes high, and it overcomes the 2GB Ram and crashes. And the error on the logs (which is attached at the end), points to admin.$cmd what appear in other warnings before without another impact. This issue can not happen for a week, and suddenly happens a day 6am when nobody is calling the server. I suspect some internal MongoDB usage.
Does anyone have a TIP on why the CPU usage peaks appear or how to avoid them? I could always upgrade the VM or use MongoDB atlas but has no sense that this happens in a VM in which traffic is almost unexisting
{"t":{"$date":"2023-01-11T07:32:53.117+00:00"},"s":"I", "c":"COMMAND", "id":23099, "ctx":"PeriodicTaskRunner","msg":"Task finished","attr":{"taskName":"DBConnectionPool-cleaner","durationMillis":1437}}
{"t":{"$date":"2023-01-11T07:32:35.867+00:00"},"s":"I", "c":"COMMAND", "id":51803, "ctx":"conn29","msg":"Slow query","attr":{"type":"command","ns":"admin.$cmd","command":{"ismaster":1,"$db":"admin"},"numYields":0,"reslen":304,"locks":{},"remote":"127.0.0.1:53792","protocol":"op_msg","durationMillis":43549}}
{"t":{"$date":"2023-01-11T07:31:52.574+00:00"},"s":"I", "c":"COMMAND", "id":51803, "ctx":"LogicalSessionCacheReap","msg":"Slow query","attr":{"type":"command","ns":"config.transactions","command":{"find":"transactions","filter":{"lastWriteDate":{"$lt":{"$date":"2023-01-11T06:58:42.761Z"}}},"projection":{"_id":1},"sort":{"_id":1},"readConcern":{},"$db":"config"},"planSummary":"EOF","keysExamined":0,"docsExamined":0,"cursorExhausted":true,"numYields":0,"nreturned":0,"queryExecutionEngine":"classic","reslen":108,"locks":{"FeatureCompatibilityVersion":{"acquireCount":{"r":3}},"ReplicationStateTransition":{"acquireCount":{"w":1}},"Global":{"acquireCount":{"r":3}},"Mutex":{"acquireCount":{"r":2}}},"readConcern":{"provenance":"implicitDefault"},"storage":{},"protocol":"op_msg","durationMillis":109845}}