cloudfoundry java buildpack 内存更改未反映
cloudfoundry java buildpack memory changes not reflecting
我想在 cloudfoundry java-buildpack 中更改我的 java 应用程序的内存设置。我试过这两种方式:
- 在我的 manifest.yml 中使用 JBP_CONFIG_OPEN_JDK_JRE 参数。作为
建议在
https://github.com/cloudfoundry/java-buildpack-memory-calculator
- 在 config\open_jdk_jre.yml:
中进行此更改
memory_calculator:
version: 3.8.0_RELEASE
repository_root:
"{default.repository.root}/memory-calculator/{platform}/{architecture}"
stack_threads: 300
memory_sizes:
stack: 2M
metaspace: 160M
heap: 900M
但是,none 在部署我的应用程序时会反映出来。我正在使用最新的 java-buildpack。
这取决于您使用的 Java 构建包的版本。
版本3.x
对于版本 3.x,您可以设置一个环境变量来配置内存计算器。喜欢这里
https://github.com/cloudfoundry/java-buildpack/tree/3.x#configuration-and-extension
例如:
cf set-env my-application JBP_CONFIG_OPEN_JDK_JRE '{ memory_calculator: { memory_heuristics: { heap: 85, stack: 10 } } }'
这将覆盖构建包中默认的内存启发式配置,特别是堆和堆栈权重。
一些注意事项:
- 了解不同内存配置选项的作用是另一回事。你可以阅读那些 here.
- 这仅适用于 OpenJDK,如果您使用不同的 JDK,则配置选项会略有不同。例如:
JBP_CONFIG_ORACLE_JRE
对于 Oracle。该名称反映了 config file path & name.
- 如何为您的应用设置 env 变量并不重要。您可以像上面那样使用
cf set-env
或者您可以在 manifest.yml 文件中设置 env 变量。两者都工作得很好。
版本4.x
在版本4.x中,JVM 内存设置的配置变得更加简单。
however if you believe that your application doesn’t need these JVM defaults, you can now configure those memory regions directly with JVM options.
https://www.cloudfoundry.org/just-released-java-buildpack-4-0/
这意味着您仍然通过环境变量配置 JVM 设置,但您只需要设置 JAVA_OPTS
并使用标准的 JVM 配置选项。
例如:
cf set-env my-app JAVA_OPTS '-XX:ReservedCodeCacheSize=100M'
如果您更喜欢在 manifest.yml 中设置 JAVA_OPTS
而不是 运行 cf set-env
.
希望对您有所帮助!
我遇到了类似的问题 - stackThreads 的设置被忽略了。我不清楚
- JavaBuildPack-4 是否支持像这样的配置
'{memory_calculator: {stack_threads: 202 } }'
- 它是否仅在 JBP-3 中受支持,而 JBP-4 没有配置线程的选项
- 是否按照
https://docs.cloudfoundry.org/buildpacks/java/java-tips.html 和
https://github.com/cloudfoundry/java-buildpack/issues/416使用
右尖括号 JBP_CONFIG_OPEN_JDK_JRE: '[memory_calculator:
{memory_sizes: {native: 150m}}]'
- 是否按照建议使用单引号 here 当在命令行上只接受双引号时 cf set-env ...
我最终下载了 source code for JBP-4 and saw that it does indeed still support JBP_CONFIG_OPEN_JDK_JRE (just not all the memory settings that were supposed in JBP-3). Daniel Mikusa supplied the most valuable tip in
... 使用 Oracle JRE 时,使用 JBP_CONFIG_ORACLE_JRE.
在 ",',[{ 的所有排列中,这是有效的;
cf set-env APP_NAME JBP_CONFIG_ORACLE_JRE "{memory_calculator: {stack_threads: 202 } }"
我想在 cloudfoundry java-buildpack 中更改我的 java 应用程序的内存设置。我试过这两种方式:
- 在我的 manifest.yml 中使用 JBP_CONFIG_OPEN_JDK_JRE 参数。作为 建议在 https://github.com/cloudfoundry/java-buildpack-memory-calculator
- 在 config\open_jdk_jre.yml: 中进行此更改
memory_calculator:
version: 3.8.0_RELEASE
repository_root: "{default.repository.root}/memory-calculator/{platform}/{architecture}" stack_threads: 300
memory_sizes:
stack: 2M
metaspace: 160M
heap: 900M
但是,none 在部署我的应用程序时会反映出来。我正在使用最新的 java-buildpack。
这取决于您使用的 Java 构建包的版本。
版本3.x
对于版本 3.x,您可以设置一个环境变量来配置内存计算器。喜欢这里
https://github.com/cloudfoundry/java-buildpack/tree/3.x#configuration-and-extension
例如:
cf set-env my-application JBP_CONFIG_OPEN_JDK_JRE '{ memory_calculator: { memory_heuristics: { heap: 85, stack: 10 } } }'
这将覆盖构建包中默认的内存启发式配置,特别是堆和堆栈权重。
一些注意事项:
- 了解不同内存配置选项的作用是另一回事。你可以阅读那些 here.
- 这仅适用于 OpenJDK,如果您使用不同的 JDK,则配置选项会略有不同。例如:
JBP_CONFIG_ORACLE_JRE
对于 Oracle。该名称反映了 config file path & name. - 如何为您的应用设置 env 变量并不重要。您可以像上面那样使用
cf set-env
或者您可以在 manifest.yml 文件中设置 env 变量。两者都工作得很好。
版本4.x
在版本4.x中,JVM 内存设置的配置变得更加简单。
however if you believe that your application doesn’t need these JVM defaults, you can now configure those memory regions directly with JVM options.
https://www.cloudfoundry.org/just-released-java-buildpack-4-0/
这意味着您仍然通过环境变量配置 JVM 设置,但您只需要设置 JAVA_OPTS
并使用标准的 JVM 配置选项。
例如:
cf set-env my-app JAVA_OPTS '-XX:ReservedCodeCacheSize=100M'
如果您更喜欢在 manifest.yml 中设置 JAVA_OPTS
而不是 运行 cf set-env
.
希望对您有所帮助!
我遇到了类似的问题 - stackThreads 的设置被忽略了。我不清楚
- JavaBuildPack-4 是否支持像这样的配置 '{memory_calculator: {stack_threads: 202 } }'
- 它是否仅在 JBP-3 中受支持,而 JBP-4 没有配置线程的选项
- 是否按照 https://docs.cloudfoundry.org/buildpacks/java/java-tips.html 和 https://github.com/cloudfoundry/java-buildpack/issues/416使用 右尖括号 JBP_CONFIG_OPEN_JDK_JRE: '[memory_calculator: {memory_sizes: {native: 150m}}]'
- 是否按照建议使用单引号 here 当在命令行上只接受双引号时 cf set-env ...
我最终下载了 source code for JBP-4 and saw that it does indeed still support JBP_CONFIG_OPEN_JDK_JRE (just not all the memory settings that were supposed in JBP-3). Daniel Mikusa supplied the most valuable tip in
在 ",',[{ 的所有排列中,这是有效的;
cf set-env APP_NAME JBP_CONFIG_ORACLE_JRE "{memory_calculator: {stack_threads: 202 } }"