MongoDB - Deployment

MongoDB - Deployment

When you are preparing a MongoDB deployment, you should try to understand how your application will work 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 as you work.

The best approach involves prototyping your rig, doing load testing, monitoring key metrics, and using that information to scale your rig. A key part of this approach is proactive monitoring of your entire system - this will help you understand how your production system will perform prior to deployment and determine where you will need to increase capacity. For example, understanding potential spikes in memory usage can help dampen a write lock 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, deletions, and cursors. The command also shows when you encounter page faults and shows your block percentage. This means you don't have enough memory, you don't have enough write capacity, or you have performance issues.

To run the command, start your Mongod instance. On another command line, change 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 monitors and reports the read and write activity of a collection-based MongoDB instance. By default , mongotop returns information every second, which you can change accordingly. You need to make sure that this read/write operation matches your application intent and you don't run too many writes to the database at one time, read too often from disk, or exceed the working set size.

To run the command, start your Mongod instance. On another command line, change to the bin directory of your mongodb installation and type mongotop .

D:\setup\mongodb\bin>mongotop

Following is the output of the command −

mongotop

To make the mongotop command return information less frequently, include a specific number after the mongotop command.

D:\set up\mongodb\bin>mongotop 30

The above example will return values ‚Äč‚Äčevery 30 seconds.

In addition to MongoDB tools, 10gen provides a free hosted monitoring service, MongoDB Management Service (MMS), which provides a dashboard and allows you to view cluster-wide metrics.