Finding and terminating long-running operations in MongoDB

When your MongoDB becomes unresponsive, it’s imperative that you can quickly identify the cause.

Although there can be many reasons for unresponsiveness, we sometimes find that particularly long-running and/or blocking operations (either initiated by a human or an application) are the culprit. Some examples of common operations that can bog down the database are:

  • operations on unindexed fields

  • index builds

  • expensive map-reduce jobs

One way to quickly see if one or more operations are particularly long-running is to use db.currentOp().

Continue Reading →

{ "comments": 7 }

Managing disk space in MongoDB

In our previous post on MongoDB storage structure and dbStats metrics, we covered how MongoDB stores data and the differences between the dataSize, storageSize and fileSize metrics. We can now apply this knowledge to evaluate strategies for re-using MongoDB disk space.

When documents or collections are deleted, empty record blocks within data files arise. MongoDB attempts to reuse this space when possible, but it will never return this space to the file system. This behavior explains why fileSize never decreases despite deletes on a database.

If your app frequently deletes or if your fileSize is significantly larger than the size of your data plus indexes, you can use one of the methods below reclaim free space. Continue Reading →

{ "comments": 8 }

How big is your MongoDB?

Update 11/10/14: The next blog post in this series is on managing disk space in MongoDB.

As your MongoDB grows in size, information from the db.stats() diagnostic command (or the database “Stats” tab in our management portal) becomes increasingly helpful for evaluating hardware requirements.

We frequently get questions about the dataSize, storageSize and fileSize metrics, so we want to help developers better understand how MongoDB storage works and what these particular metrics mean.

Continue Reading →

{ "comments": 11 }

MongoLab Now Supports Two-Factor Authentication

(Updated: 2014-01-08 Two-factor authentication is now GA)

Here at MongoLab, security is one of our foremost concerns.  Part of our stewardship of our users’ data, in addition to keeping it accessible and intact, is doing our best to secure it against unauthorized access. Today, as part of that effort, we are excited to announce our adoption of two-factor authentication (“2FA”) for MongoLab’s web-based management portal.

If you keep tabs on the glamorous InfoSec scene you probably already know what 2FA is and exactly why you should care. If that’s you, feel free to skip on down to the punchline in the last paragraph. Otherwise, bear with me and I’ll try to explain why an extra screen in your MongoLab login sequence might be a Very Good Thing indeed.

Continue Reading →

{ "comments": 2 }

Deep Dive into Connection Pooling

As your application grows in functionality and/or usage, managing resources becomes increasingly important. Failure to properly utilize connection pooling is one major “gotcha” that we’ve seen greatly impact MongoDB performance and trip up developers of all levels.

Connection pools

Creating new authenticated connections to the database is expensive. So, instead of creating and destroying connections for each request to the database, you want to re-use existing connections as much as possible. This is where connection pooling comes in.

A Connection Pool is a cache of database connections maintained by your driver so that connections can be re-used when new connections to the database are required. When properly used, connection pools allow you to minimize the frequency and number of new connections to your database.

Continue Reading →

{ "comments": 27 }

Round Two: Node Knockout 2013!

Screen Shot 2013-10-30 at 11.28.16 AM

Hey Node hackers!

Given last year’s tremendous turnout and success, MongoLab is very happy to sponsor Node Knockout (Nov 8-10) once again. If you’re wondering what the buzz is about, Node Knockout is a 48-hour hackathon featuring Node.js. It’s an online virtual competition with contestants worldwide. The competition kicks off at 12:00 AM / 00:00 UTC on November 9, 2013 and ends at 12:00 AM / 00:00 UTC on November 11, 2013. There are still a few spots open on some teams, so reach out to our friends organizing the event if you’re interested!

MongoLab will be offering both service and prize sponsorships for participating teams. This means that during the competition your team can sign up for a free 500MB Joyent-hosted MongoDB. We’ve partnered with Joyent and Nodejitsu to bring you the lowest latency possible between your knockout app and MongoDB.

Continue Reading →

Do you want a timeout?

You’re feeling accomplished and excited; the new features for your application are finished, committed, and deployed. You fire it up, expecting your shiny new app on your screen. Unexpectedly, the app errors out or hangs indefinitely.

What’s going on?!

You may have just had your first direct encounter with the subtleties of your MongoDB driver’s connection options.

At a high level, whenever you create or use a MongoClient object to talk to your database, the driver establishes a connection to your MongoDB server. How long your application waits for the initial connection to be established and how long it waits for responses to subsequent requests is determined by the values of your connection and socket timeouts.

Continue Reading →

{ "comments": 1 }

Are you ready for production?

Updated article on 03/24/15

Transitioning your application from development to production is a monumental step. Over the years, we at MongoLab have acquired a lot of valuable experience helping our customers successfully manage their production-grade MongoDB deployments.

What follows is a checklist of action items that we’ve found imperative for successfully taking your application to production. For the experienced, we hope you can use this guide as a refresher on best practices. For the newer folks, this is a must-read on how to ready your database for the big move.

Continue Reading →