Jay Taylor's notes
back to listing indexDisable Transparent Huge Pages (THP) — MongoDB Manual 3.0
[web search]MongoDB Manual 3.0 (current)
- Installation
- MongoDB CRUD Operations
- Data Models
- Administration
- Administration Concepts
- Administration Tutorials
- Configuration, Maintenance, and Analysis
- Disable Transparent Huge Pages (THP)
- Use Database Commands
- Manage mongod Processes
- Terminate Running Operations
- Analyze Performance of Database Operations
- Rotate Log Files
- Manage Journaling
- Store a JavaScript Function on the Server
- Upgrade to the Latest Revision of MongoDB
- Monitor MongoDB With SNMP on Linux
- Monitor MongoDB Windows with SNMP
- Troubleshoot SNMP
- Disable Transparent Huge Pages (THP)
- Backup and Recovery
- MongoDB Scripting
- MongoDB Tutorials
- Configuration, Maintenance, and Analysis
- Administration Reference
- Production Checklist
- Security
- Aggregation
- Indexes
- Storage
- Replication
- Sharding
- Frequently Asked Questions
- Reference
- Release Notes
- Contribute to the MongoDB Project
-
Version
- Formats
- Contribute
- Administration >
- Administration Tutorials >
- Configuration, Maintenance, and Analysis >
- Disable Transparent Huge Pages (THP)
Disable Transparent Huge Pages (THP)
Transparent Huge Pages (THP) is a Linux memory management system that reduces the overhead of Translation Lookaside Buffer (TLB) lookups on machines with large amounts of memory by using larger memory pages.
However, database workloads often perform poorly with THP, because they tend to have sparse rather than contiguous memory access patterns. You should disable THP on Linux machines to ensure best performance with MongoDB.
Init Script
Important:
If you are using tuned or ktune (for example, if you are running Red Hat or CentOS 6+), you must additionally configure them so that THP is not re-enabled. See Using tuned and ktune.
Create the init.d script.
Create the following file at /etc/init.d/disable-transparent-hugepages:
Make it executable.
Run the following command to ensure that the init script can be used:
Configure your operating system to run it on boot.
Use the appropriate command to configure the new init script on your Linux distribution.
Distribution | Command |
---|---|
Ubuntu and Debian | |
SUSE | |
Red Hat, CentOS, Amazon Linux, and derivatives |
Override tuned and ktune, if applicable
If you are using tuned or ktune (for example, if you are running Red Hat or CentOS 6+) you must now configure them to preserve the above settings.
Using tuned and ktune
Important:
If using tuned or ktune, you must perform this step in addition to installing the init script.
tuned and ktune are dynamic kernel tuning tools available on Red Hat and CentOS that can disable transparent huge pages.
To disable transparent huge pages in tuned or ktune, you need to edit or create a new profile that sets THP to never.
Red Hat/CentOS 6
Create a new profile.
Create a new profile from an existing default profile by copying the relevant directory. In the example we use the default profile as the base and call our new profile no-thp.
Edit ktune.sh.
Edit /etc/tune-profiles/no-thp/ktune.sh and add the following:
to the start() block of the file, before the return 0 statement.
Enable the new profile.
Finally, enable the new profile by issuing:
Red Hat/CentOS 7
Create a new profile.
Create a new tuned profile directory:
Edit tuned.conf.
Create and edit /etc/tuned/no-thp/tuned.conf so that it contains the following:
Enable the new profile.
Finally, enable the new profile by issuing:
Test Your Changes
You can check the status of THP support by issuing the following commands:
On Red Hat Enterprise Linux, CentOS, and potentially other Red Hat-based derivatives, you may instead need to use the following:
For both files, the correct output resembles:
© MongoDB, Inc 2008-2015. MongoDB, Mongo, and the leaf logo are registered trademarks of MongoDB, Inc.