Expensive mongoDB Calls

Using MongoDB instead of the good old relational storage will not remove performance issues. The remote and blocking nature of such calls coupled with expensive operations inside the database still means you are facing performance issues while interacting with the MongoDB.

Start your free trial

How Plumbr will help you

The screenshot above is an example from the real application exposing a Slow MongoDB Operation as a root cause for poor user experience. It is visible that the query to apiPartners.findOne(?) in the MongoDB instance located at ds44112.mongolab.com:12345 took almost five seconds to complete. As a result, the end user was forced to wait too long for the particular user interaction to complete.

It is also visible that this was not an isolated case. The very same apiPartners.findOne(?) call has been too slow on 1,350 times during the last seven days.

The details of the operation are visible in the two sections below. First of them exposes the exact call along with the parameters passed:

  "id" : "52d9a72cfd41970f90639522"

The block on the bottom right exposes the call stack through which the call was made:


In addition, Plumbr exposes you the full view of the transaction where this particular slow MongoDB operation participated. Opening the details for the transaction exposes the following information:

From the above it is clear that the particular call to apiPartners.findOne(?) contributed almost half of the total 10 seconds the entire transaction took to complete. There were other calls to MongoDB present, also contributing towards the poor user experience, but the particular call is contributing the most.

The Solution

Solving MongoDB-related performance issues is not different from other performance issues caused by external datastores responding too slowly. In general, optimizing the performance in case of slow MongoDB calls tends to involve one or more of the following techniques:

  • Optimizing the network round-trip
  • Optimizing the remote system response times
  • Decoupling the remote call to an asynchronous method invocation
  • Caching the information fetched from the remote system locally
  • Batching multiple calls to the remote system to one large batch

Start your free trial