Not able to set JVM heap size on AWS Elastic Beanstalk Java SE Platform
Asked Answered
F

2

1

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

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:

  • 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

What else could I try?

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.

Fructificative answered 26/2, 2018 at 14:4 Comment(0)
F
1

I solved it!

My Spring Boot project was a multi-module one:

  • base_module (POM type)
    • .elasticbeanstalk
      • config.yaml
    • module1 (delpyed module. imports module2 and module3 in the pom.xml)
    • module2
    • module3
    • Procfile

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

So the command eb deploy wasn't taking in account the 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

The final project structure was:

  • base_module (POM type)
    • module1 (delpyed module. imports module2 and module3 in the pom.xml)
      • .elasticbeanstalk
        • config.yaml
      • src
      • target
    • Procfile
    • module2
    • module3

Hope it helps somebody!

Fructificative answered 27/2, 2018 at 19:13 Comment(1)
when running this configuration you indeed get something like : ps aux | grep java returning java - jar jarname.jar -Xms2g -Xmx4g . However, when running sudo jmap -heap [process pid] you get a 2GB maximum heapsize (in my case on an 8GB Elastic Beanstalk server). What could be happening?Buschi
G
0

Create a zip file which contains your application.jar and the Proc file.Upload and deploy this in the elasticbeanstalk.

Write the below line in your Procfile web: java -jar application.jar -Xmx896M

Gaming answered 21/3, 2018 at 14:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.