If you are using a Linux system, you need to manage extra setup to improve performance or to resolve production problems with many indices.
This recipe covers two common errors that happened in production:
You need a working Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in this chapter and a simple text editor to change configuration files.
For improving the performances on Linux systems, we will perform the following steps:
elasticsearch
./etc/security/limits.conf
and add these lines at the end:elasticsearch - nofile 65536 elasticsearch - memlock unlimited
/etc/security/limits.conf
in init.d
scripts; in these cases you need to edit /etc/pam.d/su
and uncomment the following line:# session required pam_limits.so
elasticsearch.yml
:bootstrap.memory_lock
ES_MIN_MEM
and ES_MAX_MEM
in $ES_HOME/bin/elasticsearch.in.sh
. You can otherwise setup ES_HEAP_SIZE
that automatically initializes the min and max values to the same.The standard limit of file descriptors (max number of open files for user) is typically 1024
. When you store a lot of records in several indices, you run out of file descriptors very quickly, so your Elasticsearch server becomes unresponsive and your indices may become corrupted and as a result make you lose your data.
Changing the limit to a very high number, your Elasticsearch doesn't hit the maximum number of open files.
The other settings for memory prevent Elasticsearch swapping memory and give a performance boost in a production environment. This setting is required because during indexing and searching Elasticsearch creates and destroys a lot of objects in memory. This large number of create/destroy actions fragments the memory reducing performances: the memory becomes full of holes and when the system needs to allocate more memory it suffers an overhead to find compacted memory. If you don't set bootstrap.memory_lock: true
, Elasticsearch dumps the whole process memory on disk and defragments it back in memory, freezing the system. With this setting, the defragmentation step is done all in memory, with a huge performance boost.
18.118.20.68