如何在灵活的GAE应用程序中正确设置JVM选项 [英] How to properly set the JVM options in a flexible GAE application

查看:106
本文介绍了如何在灵活的GAE应用程序中正确设置JVM选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的GAE flexible Java 8/Jetty应用程序的app.yaml文件.

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

由于某些原因,在部署应用程序时未使用JAVA_HEAP_OPTS值.至少我不认为这是有用的,因为当我SSH进入docker容器并运行以下命令时,内存值要少得多.

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?

谢谢

推荐答案

该变量仅适用于作为docker容器入口点运行的Java进程.

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

JAVA_HEAP_OPTS不是一个魔术环境变量,它会自动并全局地应用于docker容器内Java的任何随机执行.难怪在启动自己的独立Java进程时为什么看不到任何效果.

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

这篇关于如何在灵活的GAE应用程序中正确设置JVM选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆