WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2019-11-12T07:35:01.030-0500 I CONTROL [initandlisten] ** We suggest setting it to 'never'
WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-11-12T08:59:41.969-0500 I CONTROL [initandlisten] ** We suggest setting it to 'never'
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 enabled, because they tend to have sparse rather than contiguous memory access patterns. When running MongoDB on Linux, THP should be disabled for best performance.
To ensure that THP is disabled before mongod starts, you should create a new systemd unit:
1-Create the file /etc/systemd/system/disable-thp.service:
2-Enable the new unit:
THP will now be disabled. However, already allocated huge pages are still active. Rebooting the server is advised to bring up the services with THP disabled.