Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Elastic Beanstalk and JAVA_OPTS

I have a java application which is deployed to Elastic Beanstalk. There are two environments: test and production, production is configured to use bigger instances than test. With the default config for java environment max heap size is around 1/4 of all instance RAM (for 2G RAM instance it's about 0.5G) and I'd like to increase it (-Xmx). Available options are:

  • using .ebextensions - this way config for both environment will be the same (not good)
  • using Procfile - the same as above
  • using Environment properties in console does not work - those properties are passed to application (-D), not to java.

Any ideas how to set -Xmx depending on environment / available memory size? Thanks

like image 996
Cyprian Gracz Avatar asked Sep 09 '26 03:09

Cyprian Gracz


1 Answers

I think of two ways to resolve the issue:

  1. two sets of .ebextensions, one for test and one for prod, when you do the app package, just put .ebextensions under webapp folder, it will be picked up by Beanstalk

  2. customized catalina.sh to grep the free memory and adjust the -Xmx accordingly.

like image 192
chenrui Avatar answered Sep 11 '26 18:09

chenrui



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!