Updated on 2024-11-29 GMT+08:00

Disabling Swapping

Most operating systems use as much memory as possible for the file system cache and release unused application memory. This may cause some JVM heap memory to be swapped to disks.

This swapping is very bad for performance and node stability, and should be avoided at all costs. It may lead to garbage collection for a few minutes rather than a few milliseconds, which may result in slow node response and even disengagement from the cluster.

In the Linux/Unix system, mlockall is used to lock the address space of the process in the RAM to prevent the Elasticsearch memory from being swapped out. In this way, Swapping is disabled.

To enable the bootstrap.memory_lock parameter, perform the following steps:

  1. Log in to Manager as an administrator and choose Cluster > Name of the desired cluster > Services > Elasticsearch > Configurations > All Configurations > Elasticsearch > Self-Definition.
  2. Modify the value of elasticsearch.customized.configs, add the bootstrap.memory_lock parameter, set it to true, and click Save to save the configuration and restart the Elasticsearch service.
  3. Log in to any Elasticsearch data node as the root user and run the following command to check whether the modification is successful. If the command output contains true, the modification is successful. httpport indicates the HTTP port of the Elasticsearch instance.

    curl -XGET --tlsv1.2 --negotiate -k -u : "https://ip:httpport/_nodes?filter_path=**.mlockall"