How to optimize your MongoDB cluster

Hello here. I’m working on a MongoDB project for a while now and I faced several sorts of issues that I succeed in fixing them. The first one was the configuration of the cluster (using an arbiter in replica set), I already shared the “how to” here. The cluster is processing a lot of data (120 GB by the day) and also handle a lot of query through an API or directly on routers. After one week we started to have performance issues. After some investigation I found some parameters which can be tweaked to increase performance and I’m about to share them in this article.

Number of open files on the system

MongoDB needs to open a lot of files on the file system. This is why you need to monitor this parameter to check if it is correctly set. Depending on your needs, by increasing the parameter on each node of the cluster it can improve its performance. This parameter is set at the file system level not on MongoDB.


This parameter is set to define the maximum size of the internal cache that WiredTiger will use for all data. The default value is 50% of (RAM – 1 GB), or 256 MB. So if you can use more than 50% of your RAM, by increasing this parameter you can significantly increase the performance of your cluster. You pass the value when you launch the mongod by adding this: --wiredTigerCacheSizeGB 100GB if you want to set it to 100 GB for example. You need to define this on all replicas set.


This parameter limit the number of simultaneous connections that mongod can accept. So if your cluster will process lot of queries simultaneously, by increasing this parameter you can significantly increase the performance of your cluster (by reducing the number of requests put in pending). You can set this parameter on each node of your cluster. Like the previous parameter you also pass this parameter when you launch the mongod by adding this --maxConns 100 for 100 connections, for example.


For now, those are the parameters I tweaked on my cluster to improve performance. You can check the MongoDB official documentation for more information and you can also leave a comment if you know some other parameters which can help. Thanks you.

No Comments

Leave a reply