无法在AWS Elastic Beanstalk Java SE平台上设置JVM堆大小 [英] Not able to set JVM heap size on AWS Elastic Beanstalk Java SE Platform

查看:80
本文介绍了无法在AWS Elastic Beanstalk Java SE平台上设置JVM堆大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Elastic Beanstalk上使用单个EC2 t2.micro实例(1GB RAM)部署了一个Spring Boot应用程序.

I have a Spring Boot app deployend on Elastic Beanstalk using a single EC2 t2.micro instance (1GB RAM).

我需要增加应用程序的JVM堆大小,但无法这样做.我尝试过的事情是:

I need to increase my app's JVM Heap size but I'm not being able to do so. The things I have tried are:

  • 在EB控制台的环境配置中使用值-Xms512m -Xmx896m设置JAVA_OPTS变量.
  • 在项目根文件夹中使用Procfile部署应用程序,其中包含以下行:web: java -jar <relative-path-to-jar> -Xms512m -Xmx896m
  • Setting a JAVA_OPTS variable in the enviroment configuration in the EB console with the value -Xms512m -Xmx896m.
  • Deploying the app with a Procfile in the project root folder what contains the following line: web: java -jar <relative-path-to-jar> -Xms512m -Xmx896m

我还能尝试什么?

注意:要检查我ssh进入实例的运行应用程序的JVM堆大小,并使用jstat命令作为此答案描述.计算最大值总是得到256MB,这就是dafault.

Note: To check the JVM heap size of the running app I ssh into the instance and use the jstat command as this answer describes. Calculating the max value always gives me 256MB which is the dafault.

推荐答案

我解决了!

我的Spring Boot项目是一个多模块项目:

My Spring Boot project was a multi-module one:

  • base_module(POM类型)
    • .elasticbeanstalk
      • config.yaml
      • base_module (POM type)
        • .elasticbeanstalk
          • config.yaml

          其中一个模块(我正在部署的一个jar)导入了其他模块.我的错误是我将Procfile放在基本模块的根目录中.同样在config.yaml文件中,我输入了以下几行:

          One of the modules (the one's jar I was deploying) imported the other ones. My mistake was that I was putting the Procfile in the root of the base module. Also in the config.yaml file I was putting the following lines:

          deploy:
              artifact: module1/target/app.jar
          

          因此,命令eb deploy没有考虑Procfile.

          解决方案是将.elasticbeanstalk文件夹移到module1文件夹,从config.yaml中删除我上面所说的行,并在module1的根目录中添加以下行:Procfile:

          The solution was to move the .elasticbeanstalk folder into the module1 folder, removing the lines I said above from the config.yaml and to add a Procfile in the root of module1 with the following line:

          web: java -jar target/app.jar -Xmx896M
          

          最终的项目结构为:

          • base_module(POM类型)
            • module1(绑定的模块.将pom.xml中的module2和module3导入)
              • .elasticbeanstalk
                • config.yaml
                • base_module (POM type)
                  • module1 (delpyed module. imports module2 and module3 in the pom.xml)
                    • .elasticbeanstalk
                      • config.yaml

                      希望对您有所帮助!

                      这篇关于无法在AWS Elastic Beanstalk Java SE平台上设置JVM堆大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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