Skip to content

Instantly share code, notes, and snippets.

View gofabian's full-sized avatar

Fabian Iffländer gofabian

View GitHub Profile
@gofabian
gofabian / tomcat_memory.md
Created October 5, 2020 13:28 — forked from mlconnor/tomcat_memory.md
Memory settings for Java JVM in Amazon Elastic Beanstalk

Elastic Beanstalk Java JVM Settings

Determining the right memory settings (MX & MS) for the JVM is not trivial. If you set memory too low then your machine will trash as it runs out and eventually crash. If you set it too high then other critical processes such as Apache or the OS itself may become memory starved and also cause crashes.

In general, I think it best to set the initial memory setting (MS) to be small, around 200M. The real variable we need to calculate is the limit we will place on JVM memory (MS).

In order to make this determination, we need to calculate a few things such as the memory that Apache and the Linux OS need to operate efficiently.

Apache Memory Needs

# (1) use Alpine Linux for build stage
FROM alpine:3.10.1 as build
# (2) install build dependencies
RUN apk --no-cache add openjdk11
RUN apk --no-cache add maven
# build JDK with less modules
RUN /usr/lib/jvm/default-jvm/bin/jlink \
--compress=2 \
--module-path /usr/lib/jvm/default-jvm/jmods \