Quantcast
Channel: mongodb – SitePoint
Viewing all articles
Browse latest Browse all 37

7 Simple Speed Solutions for MongoDB

$
0
0

MongoDB is a fast NoSQL database. Unfortunately, it is not a cure for all your performance woes and a single complex query can bring your code grinding to a halt. I recently suffered this fate and it can be difficult to know where to look when your application suddenly becomes unstable. I hope these tips help you avoid the pain I went through!

1. Check Your MongoDB Log

By default, MongoDB records all queries which take longer than 100 milliseconds. Its location is defined in your configuration's systemLog.path setting and it's normally /var/log/mongodb/mongod.log in Debian-based distributions such as Ubuntu.

The log file can be large so you may want to clear it before profiling. From the mongo command-line console, enter:

[code]
use admin;
db.runCommand({ logRotate : 1 });
[/code]

A new log file will be started and the old data will be available in a file named with the back-up date and time. You can delete the back-up or move it elsewhere for further analysis.

It can also be useful to watch the log while users are accessing your system, e.g.

[code]
tail -f /var/log/mongodb/mongod.log
[/code]

Continue reading %7 Simple Speed Solutions for MongoDB%


Viewing all articles
Browse latest Browse all 37

Trending Articles