Monday , October 7 2024

How To Improve Database Performance on MongoDB Part2

 

This article is the second part of the article named “How to improve database performance on MongoDB part 1

Ensure you have enough RAM.

As other Database Managers, MongoDB performs best when the portion of your data that clients access most often live in RAM. RAM size is the most important factor for hardware.

To calculate how much RAM you need, you must calculate your working set size or the portion of your data that clients use most often.

This depends on:

  • Your access patterns
  • What indexes you have and the size of your documents
  • The relationship between database storage and working set
  • Each database connection thread will need up to 1 MB of RAM, whether active or idle
  • The impact of the journaling
  • Your Storage Engine
  • Your type of Disk
  • How many mongod processes are running on the server
  • If your server is dedicated for MongoDB or not

The easy way to check if you have RAM problems is running the command from mongo shell:

 

Server without stress:

Server with stress:

The extra_info.page_faults counter may increase dramatically during moments of poor performance and may correlate with limited memory environments and larger datasets. Limited and sporadic page faults do not necessarily indicate an issue. This counter needs to be monitored.

In your mongod log entry you see:

By the way, I have an insufficient amount of RAM.

For good manage of RAM, I recommend:

  • Use WireTiger storage Engine
    • Configure compression
    • If you need to run multiple mongod processes, it’s necessary to calculate the appropriate cache size for each instance by evaluating what portion of total RAM each of them should use, and splitting the default cache_size between each
    • Avoid set chace_size over the default value, you could experience poor performance
  • Use SSDs for write-heavy applications
  • Dedicate role server, avoid the usage of database servers for running no MongoDB process
  • Consider sharding your database across multiple servers

You may want to read the other article of this series “How To Improve Database Performance on MongoDB Part3

Loading

About Daniel Cruz

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories