There are two rules to apply when setting the Elasticsearch heap size, with
the $ES_HEAP_SIZE
environment variable:
- No more than 50% of available RAM
-
Lucene makes good use of the filesystem caches, which are managed by the kernel. Without enough filesystem cache space, performance will suffer. Furthermore, the more memory dedicated to the heap means less available for all your other fields using doc values.
- No more than 32 GB
-
If the heap is less than 32 GB, the JVM can use compressed pointers, which saves a lot of memory: 4 bytes per pointer instead of 8 bytes.
For a longer and more complete discussion of heap sizing, see [heap-sizing]