Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment JVM heap size in docker-compose ignored #169

Closed
vitohuang opened this Issue Sep 8, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@vitohuang
Copy link

vitohuang commented Sep 8, 2017

ES_JAVA_OPTS: "-Xmx256m -Xms256m"

The above environment get ignore because the elastic search jvm setting take preceding, see the following

vito@vito-MacBook ~/dev/docker-elk $ docker exec -i -t dockerelk_elasticsearch_1 /bin/bash
[elasticsearch@57f7a2d39e39 ~]$ pwd
/usr/share/elasticsearch
[elasticsearch@57f7a2d39e39 ~]$ ls
LICENSE.txt  NOTICE.txt  README.textile  bin  config  data  lib  logs  modules  plugins
[elasticsearch@57f7a2d39e39 ~]$ cat config/jvm.options
## JVM configuration

################################################################
## IMPORTANT: JVM heap size
################################################################
##
## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms2g
-Xmx2g

################################################################
## Expert settings
################################################################
##
## All settings below this section are considered
## expert settings. Don't tamper with them unless
## you understand what you are doing
##
################################################################

## GC configuration
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75

As you can see the 2G will override in the environment.

Maybe we can make some change to the Dockerfile that will do a search and replace, then the memory limit will be taken from environment.

@vitohuang vitohuang changed the title JVM environment size in docker-compose get ignored Environment JVM heap size in docker-compose ignored Sep 8, 2017

@antoineco

This comment has been minimized.

Copy link
Collaborator

antoineco commented Sep 8, 2017

@vitohuang what does ps auxww return?

@vitohuang

This comment has been minimized.

Copy link
Author

vitohuang commented Sep 8, 2017

@antoineco Thanks for looking at it.

Here is the result

[elasticsearch@57f7a2d39e39 ~]$ ps auxww
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
elastic+     1  2.2 23.7 2860760 423552 ?      Ssl  20:42   4:20 /usr/lib/jvm/jre-1.8.0-openjdk/bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Djdk.io.permissionsUseCanonicalPath=true -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j.skipJansi=true -XX:+HeapDumpOnOutOfMemoryError -Des.cgroups.hierarchy.override=/ -Xmx256m -Xms256m -Des.path.home=/usr/share/elasticsearch -cp /usr/share/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch
elastic+    45  0.0  0.4  67936  7860 ?        Sl   20:42   0:00 /usr/share/elasticsearch/plugins/x-pack/platform/linux-x86_64/bin/controller
elastic+   162  1.0  0.1  11776  2924 pts/0    Ss   23:54   0:00 /bin/bash
elastic+   178  0.0  0.1  47448  3240 pts/0    R+   23:54   0:00 ps auxww
[elasticsearch@57f7a2d39e39 ~]$

Not sure which one have the highest priority, but looking from top ES definitely use more than 256Mb

@antoineco

This comment has been minimized.

Copy link
Collaborator

antoineco commented Sep 9, 2017

The order of the options is actually correct, with the OpenJDK JVM the rightmost options are supposed to take precedence. The reason why it doesn't work in your setup will require some more investigation. Thanks for reporting!

@antoineco

This comment has been minimized.

Copy link
Collaborator

antoineco commented Sep 22, 2017

@vitohuang I enabled JMX as described in the README and opened jconsole. Here is what I see:

ls_jmx

The Heap is indeed caped to 256m.

If I change the value to 512m in the compose file:

ls_jmx

The Heap is now caped to 512m.

Can you try to reproduce?

@antoineco antoineco self-assigned this Sep 22, 2017

@vitohuang

This comment has been minimized.

Copy link
Author

vitohuang commented Sep 22, 2017

@antoineco Thanks for looking in to that.

I tried different machine and its working now.

Not sure why it doesn't work on some.

@vitohuang vitohuang closed this Sep 22, 2017

@antoineco antoineco removed the input wanted label Sep 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.