Profiling MongoDB with JProfiler

Yamuna Dulanjani
4 min readOct 3, 2019

--

We used JProfiler for analyzing the application CPU and Memory consumption. If your application is using mongoDB you can do a database profiling through JProfiler and make your application with NoSQL in a utilization way.

First of all you have to install JProfiler and integrate with your IDE. In here I’m integrating it to IntelliJ IDEA. If you are new to JProfiler you can get help from here to integrate JProfiler with IntelliJ. If your integration is successfull your IDE will be looks like below.

IntelliJ after integration the JProfiler.

To start the profiling as step one click on JProfiler icon shown above. then your project will start to build and below Session Startup window will be appeared.

Session Startup Window

There are many settings you can adjust before starting the profiling. So I’ll explain how to configure those settings when you want to profle MongoDB.

1. Call tree filters

These filters will define which classes are recorded for CPU profiling. By clicking the Edit button there, you can define your entire application or separate modules and configure different configurations for them. In here I included my entire application and choose profile type as profiled which will show all methods in the package.

Call Tree Filters

You can change this as desired and configure as you wish to ignore methods, ignore packages, high level classes etc. In here I tried to profile entire application with MongoDB, so I included com.app which is my application root.

2. Trigger Settings

Since we going to do a database profiling no any active triggers will be present. You should disable all triggers.

Trigger Settings

3. Database Settings

This is the setting where we going to setup for profiling MongoDB. In here we can enable various kind of database profiling like Rational Database Management Systems(RDBMS) , BigData and NoSQL databases.

Database Settings

In here we going to enable all settings under MongoDB and should remove the tick on the Enabled for all other options.

4. Probe Settings

You should disabled all options under probe settings since we going to monitor only MongoDB hits.

Probe Settings

5. Initial Recording profile

After setting all above settings then you should configure the recording profile. You should add a new profile and give a name for it, I use it as Mongo. Since we going to profile the MongoDB you can set the options for created profile like below.

Enable the CPU data and select the Record database as MongoDB. Other options will not be useful here so you can disable all of them.

After setting all the above options we are good to go and do our profiling. Just click OK in the Session Startup window. Then your profiling will be start recording with application.

You can do transaction which communicate with MongoDB and just stop recording then. Then go to the Databases section on left hand menu and select MongoDB. It will shows the call stack with times and frequency. In the below profile it shows like it hit 3 times (3 evt) and the final point of time consumption is find() query in Mongo.

Feel free to play with profiling and get hands on experience to build up a good quality application. Any questions or comments will be welcome.

--

--