chore: Raise max heap size of Elasticsearch to 512 MB

This value should be a sane default. Modern versions require more
resources, and nowadays any consumer hardware should be able to have
access to this amount of memory.

Additionally, do not set a lower bound on the heap size, so that unused
space isn't unnecessarily committed to the JVM.
This commit is contained in:
Antoine Cotten 2022-05-16 20:47:45 +02:00
parent 164588d301
commit 239099874a
No known key found for this signature in database
GPG Key ID: 94637E68D4A79DD0
3 changed files with 13 additions and 11 deletions

View File

@ -349,10 +349,6 @@ of them require manual changes to the default ELK configuration.
### How to specify the amount of memory used by a service ### How to specify the amount of memory used by a service
By default, both Elasticsearch and Logstash start with [1/4 of the total host
memory](https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/parallel.html#default_heap_size) allocated to
the JVM Heap Size.
The startup scripts for Elasticsearch and Logstash can append extra JVM options from the value of an environment The startup scripts for Elasticsearch and Logstash can append extra JVM options from the value of an environment
variable, allowing the user to adjust the amount of memory that can be used by each component: variable, allowing the user to adjust the amount of memory that can be used by each component:
@ -361,9 +357,10 @@ variable, allowing the user to adjust the amount of memory that can be used by e
| Elasticsearch | ES_JAVA_OPTS | | Elasticsearch | ES_JAVA_OPTS |
| Logstash | LS_JAVA_OPTS | | Logstash | LS_JAVA_OPTS |
To accomodate environments where memory is scarce (Docker for Mac has only 2 GB available by default), the Heap Size To accomodate environments where memory is scarce (Docker Desktop for Mac has only 2 GB available by default), the Heap
allocation is capped by default to 256MB per service in the `docker-compose.yml` file. If you want to override the Size allocation is capped by default in the `docker-compose.yml` file to 512 MB for Elasticsearch and 256 MB for
default JVM configuration, edit the matching environment variable(s) in the `docker-compose.yml` file. Logstash. If you want to override the default JVM configuration, edit the matching environment variable(s) in the
`docker-compose.yml` file.
For example, to increase the maximum JVM Heap Size for Logstash: For example, to increase the maximum JVM Heap Size for Logstash:
@ -371,9 +368,12 @@ For example, to increase the maximum JVM Heap Size for Logstash:
logstash: logstash:
environment: environment:
LS_JAVA_OPTS: -Xmx1g -Xms1g LS_JAVA_OPTS: -Xmx1g
``` ```
When these options are not set, both Elasticsearch and Logstash start with an upper cap of [1/4 of the total host
memory][jvm-heap] set on the JVM Heap Size.
### How to enable a remote JMX connection to a service ### How to enable a remote JMX connection to a service
As for the Java Heap memory (see above), you can specify JVM options to enable JMX and map the JMX port on the Docker As for the Java Heap memory (see above), you can specify JVM options to enable JMX and map the JMX port on the Docker
@ -436,3 +436,5 @@ See the following Wiki pages:
[ls-docker]: https://www.elastic.co/guide/en/logstash/current/docker-config.html [ls-docker]: https://www.elastic.co/guide/en/logstash/current/docker-config.html
[upgrade]: https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-upgrade.html [upgrade]: https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-upgrade.html
[jvm-heap]: https://docs.oracle.com/en/java/javase/18/gctuning/parallel-collector1.html#GUID-74BE3BC9-C7ED-4AF8-A202-793255C864C4

View File

@ -36,7 +36,7 @@ services:
- "9200:9200" - "9200:9200"
- "9300:9300" - "9300:9300"
environment: environment:
ES_JAVA_OPTS: -Xmx256m -Xms256m ES_JAVA_OPTS: -Xmx512m
# Bootstrap password. # Bootstrap password.
# Used to initialize the keystore during the initial startup of # Used to initialize the keystore during the initial startup of
# Elasticsearch. Ignored on subsequent runs. # Elasticsearch. Ignored on subsequent runs.
@ -61,7 +61,7 @@ services:
- "5000:5000/udp" - "5000:5000/udp"
- "9600:9600" - "9600:9600"
environment: environment:
LS_JAVA_OPTS: -Xmx256m -Xms256m LS_JAVA_OPTS: -Xmx256m
LOGSTASH_INTERNAL_PASSWORD: ${LOGSTASH_INTERNAL_PASSWORD:-} LOGSTASH_INTERNAL_PASSWORD: ${LOGSTASH_INTERNAL_PASSWORD:-}
networks: networks:
- elk - elk

View File

@ -9,7 +9,7 @@ services:
volumes: volumes:
- ./extensions/enterprise-search/config/enterprise-search.yml:/usr/share/enterprise-search/config/enterprise-search.yml:ro,Z - ./extensions/enterprise-search/config/enterprise-search.yml:/usr/share/enterprise-search/config/enterprise-search.yml:ro,Z
environment: environment:
JAVA_OPTS: -Xmx2g -Xms2g JAVA_OPTS: -Xmx2g
ENT_SEARCH_DEFAULT_PASSWORD: 'changeme' ENT_SEARCH_DEFAULT_PASSWORD: 'changeme'
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD:-} ELASTIC_PASSWORD: ${ELASTIC_PASSWORD:-}
ports: ports: