How to do it…

To improve the performance on Linux systems, we will perform the following steps:

  1. First, you need to change the current limit for the user that runs the Elasticsearch server. In these examples, we will call this elasticsearch.
  2. To allow Elasticsearch to manage a large number of files, you need to increment the number of file descriptors (number of files) that a user can manage. To do so, you must edit your /etc/security/limits.conf file and add the following lines at the end:
elasticsearch - nofile 65536
elasticsearch - memlock unlimited
  1. Then, a machine restart is required to be sure that the changes have been made.
  2. The new version of Ubuntu (that is, version 16.04 or later) can skip the /etc/security/limits.conf file in the init.d scripts. In these cases, you need to edit /etc/pam.d/ and remove the following comment line:
# session required pam_limits.so
  1. To control memory swapping, you need to set up the following parameter in elasticsearch.yml:
bootstrap.memory_lock
  1. To fix the memory usage size of the Elasticsearch server, we need to set up the same values for Xmsand Xmx in $ES_HOME/config/jvm.options (that is, we set 1 GB of memory in this case), as follows:
-Xms1g
-Xmx1g