When you are preparing a MongoDB deployment, you should try to understand how your application is going to hold up in production. Itâs a good idea to develop a consistent, repeatable approach to managing your deployment environment so that you can minimize any surprises once youâre in production.
The best approach incorporates prototyping your setup, conducting load testing, monitoring key metrics, and using that information to scale your setup. The key part of the approach is to proactively monitor your entire system – this will help you understand how your production system will hold up before deploying, and determine where you will need to add capacity. Having insight into potential spikes in your memory usage, for example, could help put out a write-lock fire before it starts.
To monitor your deployment, MongoDB provides some of the following commands â
mongostat
This command checks the status of all running mongod instances and returns counters of database operations. These counters include inserts, queries, updates, deletes, and cursors. Command also shows when youâre hitting page faults, and showcases your lock percentage. This means that you’re running low on memory, hitting write capacity, or have some performance issue.
To run the command, start your mongod instance. In another command prompt, go to the bin directory of your mongodb installation and type mongostat.
D:\set up\mongodb\bin>mongostat
Following is the output of the command â
mongotop
This command tracks and reports the read and write activity of MongoDB instance on a collection basis. By default, mongotop returns information in each second, which you can change it accordingly. You should check that this read and write activity matches your application intention, and youâre not firing too many writes to the database at a time, reading too frequently from a disk, or are exceeding your working set size.
To run the command, start your mongod instance. In another command prompt, go to bin directory of your mongodb installation and type mongotop.
D:\set up\mongodb\bin>mongotop
Following is the output of the command â
To change mongotop command to return information less frequently, specify a specific number after the mongotop command.
D:\set up\mongodb\bin>mongotop 30
The above example will return values every 30 seconds.
Apart from the MongoDB tools, 10gen provides a free, hosted monitoring service, MongoDB Management Service (MMS), that provides a dashboard and gives you a view of the metrics from your entire cluster.
Thanks-a-mundo for the article.Really looking forward to read more. Want more.