Dynamic memory settings for Tomcat in latest Bitnami Tomcat AMI?

Keywords: Tomcat - AWS - How to - Other
Description:
Our current servers were based off a Bitnami Tomcat 7 AMI from 4 years ago or so. In that image there was a bitnami directory within the jre of jdk that had a variety of setenv-<instance_size>.sh files and a symbolic link that would point at the setenv file that corresponds to the current instance size. Is there something similar to that in the latest Bitnami Tomcat AMIs or will I need to manually configure this behavior?

Hi @nmb1106

Thanks for using Bitnami Tomcat!

If you want to customise the memory settings for the Java application, right now you can follow this approach here:
https://docs.bitnami.com/aws/infrastructure/tomcat/administration/configure-tomcat-memory/

Is that the equivalent of what you were trying to achieve?

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

No, that’s not comparable to what bitnami had setup in their Tomcat 7 stack. The image came out of the box with files like such:

setenv-small.sh
setenv-medium.sh
setenv-large.sh

Then had a setenv.sh symbolic link that the image would automatically update to link to the set env file for the current instance size. Each setenv file defined desired settings for the respective instance size. This was perfect for us as we use the same image for multiple instance types. It allowed us to maintain less.

Seems like this functionality doesn’t come standard anymore and we need to implement this on our own. It’s disappointing when you lose features in an upgrade but we’ll work with it. Thanks

Hi @nmb1106

I have checked that the setenv-*.sh files are not available in the latests releases of Tomcat. I will try to investigate if there is a built-in alternative approach for that and else, discuss it with the team.

Thanks for your comments

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

Hi again @nmb1106

I have been able to check that this feature is still implemented in the new releases (but in a different way). When the instance is launched, the proper vales are computed and set into /opt/bitnami/tomcat/conf/bitnami/memory.sh.

So for example, on a micro instance

$ cat /opt/bitnami/tomcat/conf/bitnami/memory.sh
export JAVA_OPTS="-Xms256M -Xmx512M $JAVA_OPTS"

However, if I launch a large instance instead:

$ cat /opt/bitnami/tomcat/conf/bitnami/memory.sh
export JAVA_OPTS="-Xms2048M -Xmx4096M $JAVA_OPTS"

Hence, you should expecting a similar behaviour :slightly_smiling_face:

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

We’ve made adjustments to the out of the box memory settings for each instance type. Is there a place I can alter what it uses for each instance type?

Hi @nmb1106

The logic that is used to set the configuration can be found under /root/.nami/components/com.bitnami.tomcat/helpers.js, in case you want to dig into it.

...
$app.helpers.resize = function(options) {
  const sizes = {
    'micro': {
      ms: '256M', mx: '512M',
    },
    'small': {
      ms: '256M', mx: '768M',
    },
...

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.