This blog represents code samples to check the MongoDB performance settings on Linux. Following configuration settings need to be checked:
MongoDB recommends to use filesystem of type XFS when using WiredTiger as storage engine with MongoDB running on Linux. The details can be found on this page, MongoDB on Linux.
Execute following command to check the filesystem:
blkid
The output would look like following:
Check MongoDB recommended values for ulimit for number of open files and number of processes/threads allowed for the user access. The details can be found on this page, Recommended ulimit settings.
Following command can be used to check value for no. of open files. The recommended value is 64000.
ulimit -n
Following command can be used to check value for no. of processes/threads. The recommended value is 64000.
ulimit -u
In addition to above, make sure that value of following is unlimited by executing corresponding commands:
MongoDB recommends disabling Transparent hugepages as MongoDB database workloads tend to have sparse rather than contiguous memory access patterns. The details can be found on this page, Disable transparent huge pages (THP).
Execute following command to check the status of THP
cat /sys/kernel/mm/transparent_hugepage/enabled cat /sys/kernel/mm/transparent_hugepage/defrag
The output of above would look like following:
Each time the data is read from a file, the filesystems perform an access-time metadata update by default. However, MongoDB (and most applications) does not use this access-time information. This means that access-time updates on MongoDB’s data volume can be disabled. A small amount of disk IO activity that the access-time updates cause, can , thus be avoided.
Use following command to check file access time setting. Note the setting noatime against MongoDb data directory
cat /etc/fstab
The following screenshot represents the output:
For WiredTiger storage engine, MongoDB recommends to set the readahead setting to 0 regardless of storage media type (spinning, SSD, etc.). Setting a higher readahead benefits sequential I/O operations. However, since MongoDB disk access patterns are generally random, setting a higher readahead provides limited benefit or performance degradation. The details on readahead limit for MongoDB can be found on this page, MongoDB production notes.
Following command can be used to get the read ahead limit for MongoDB
sudo blockdev -getra <device>
The output for above command should be 0 if MongoDB storage engine is WiredTiger. One can use command such as following to set the new ireadahead limit value:
sudo blockdev --setra <device> <value>
Execute following command to check the TCP keepalive settings
cat /proc/sys/net/ipv4/tcp_keepalive_time
The recommended value is 120. Read the details here, Does TCP keepalive time affect MongoDB deployments?. To set the keepalive settings to appropriate value, execute the following command:
sudo sysctl -w net.ipv4.tcp_keepalive_time=<value>
In recent years, artificial intelligence (AI) has evolved to include more sophisticated and capable agents,…
Adaptive learning helps in tailoring learning experiences to fit the unique needs of each student.…
With the increasing demand for more powerful machine learning (ML) systems that can handle diverse…
Anxiety is a common mental health condition that affects millions of people around the world.…
In machine learning, confounder features or variables can significantly affect the accuracy and validity of…
Last updated: 26 Sept, 2024 Credit card fraud detection is a major concern for credit…