MongoDB Transparent Huge Pages warning: when to enable or disable THP

Older MongoDB releases can warn that /sys/kernel/mm/transparent_hugepage/enabled is set to always. Check the MongoDB version first. The recommended setting changed with MongoDB 8.0.

Check the server and kernel settings

mongod --version
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag

The option in brackets is active. For example, [always] madvise never means the kernel is currently using always. Some older Red Hat-derived kernels expose the controls under /sys/kernel/mm/redhat_transparent_hugepage/. Run the checks on the database host.

Choose the setting for your version

  • MongoDB 7.0 and earlier: MongoDB recommends disabling THP for self-managed Linux deployments. Its guide covers both startup ordering and distribution-specific tuning profiles.
  • MongoDB 8.0 and later: MongoDB recommends enabling THP for its updated allocator. Follow its enablement guide for the relevant architecture and operating system.

THP is a host-wide setting. Coordinate changes with other workloads on the host, use the vendor’s boot-time configuration, and recheck both sysfs controls after applying it. Schedule a database restart if needed for the new allocation policy to take effect, then verify the service is healthy.

References: MongoDB’s version-specific THP guidance and the Linux kernel THP documentation.


Discover more from Juzhax Technology

Subscribe to get the latest posts sent to your email.