I have Java application, wrapped into Docker and hosted on Amazon ECS.
Main technologies are:
- SpringBoot 2
- Java 8
- EC2 VM with 4Gb RAM
Every 1-2 days the application is crashing and waking up again resurrected by amazon service.
Under Docker insect I found the reason:
"OOMKilled": true,
I have actuator connected to CloudWatch and I found strange behaviour with memory consumption plot:
Those blue peaks are the moments where the application has crashed.
I've read that Java 8 has some problem with reading correctly max memory for host but:
1) Docker is starting with flags that should solves the problem
ENTRYPOINT exec java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 -Xms300M -XX:PermSize100M -Djava.security.egd=file:/dev/./urandom -jar /app.jar
2) Anyway VM has 4Gb ram, so ~1.3Gb peaks high, shouldn't kill the application.
3) There wasn't any significant load on server in the moments of peaks