How to properly set the JVM options in a flexible GAE application

£可爱£侵袭症+ 提交于 2020-01-14 10:33:12

问题


the following is my app.yaml file for a GAE flexible Java 8 / Jetty application.

runtime: java
env: flex
manual_scaling:
  instances: 1

runtime_config:  # Optional
  jdk: openjdk8
  server: jetty9

resources:
  cpu: 2
  memory_gb: 4.0

env_variables:
  JAVA_HEAP_OPTS: -Xms3072M -Xmx3072M

health_check:
  enable_health_check: False

handlers:
- url: /.*
  script: this field is required, but ignored

For some reason the JAVA_HEAP_OPTS value is not used when deploying the app. A least I don't think it's used, because when I SSH into the docker container, and run the following command, the memory values are much less.

java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'

Can someone please tell me what's going or what I need to do differently?

Thanks


回答1:


The variable is applied only to the Java process that runs as the entrypoint of the docker container.

JAVA_HEAP_OPTS is not a magic environment variable that would be automatically and globally applied to any random execution of Java inside the docker container. It is no wonder why you won't see any effect when you launch your own, separate Java process.

Take a look at the following code and you will understand how it works:

  • https://github.com/GoogleCloudPlatform/openjdk-runtime/blob/9-2018-02-28_16_02/openjdk-common/src/main/docker/docker-entrypoint.bash#L32
  • https://github.com/GoogleCloudPlatform/openjdk-runtime/blob/9-2018-02-28_16_02/openjdk-common/src/main/docker/setup-env.d/30-java-env.bash#L38


来源:https://stackoverflow.com/questions/49620058/how-to-properly-set-the-jvm-options-in-a-flexible-gae-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!