MongoDB – Profiling and performance

You can retrieve the status of your server by using:

See the list of running operations in current shell:

Cautions:

  • Exercise care killing operations on secondaries (replica set)
  • Exercise care killing compact operations
  • Don’t kill internal operations – data migration / sync

mongostat

The mongostat utility provides a quick overview of the status of a currently running mongod or mongos instance.

mongotop

Mongotop tracks the amount of time a MongoDB instance spends reading and writing data.

 

Profiler

The database profiler collects fine grained data about MongoDB operations, cursors, and commands. Profiling can be enabled at database level or per MongoDB instance.

Levels of profiling :

  • 0 = off, no profiling
  • 2 = on
  • 1 = selective, show only slow operations ( > slowms)

A “new” collection will be visible. As a note, the system.profile collection is capped.

The output:

Retrieve the last profile info:

Additional links:

  1. https://docs.mongodb.org/manual/reference/command/profile/