JAVA Memory and Docker
Recently, I am working on a Java applications on ECS. It is a docker application running on the cluster.
But it keeps get killed by ECS agent. And the exception is saying, docker application is killed by memory usage.
Does that say my Java application have memory leak and go Out of Memory?
First, I checked my memory configuration on Java level. I am using -Xmx3G. My docker hard_limit and soft_limit are both 3G as well.
I am using spring framework, so I have the Perm Gen 256M.
So the VM may use memory like this: -Xmx3G + Perm Gen 256M + Other memory 217M + Xss per thread(Java Stack) = 3.5G
That might be why the ECS kill my docker applications.
Here are all the JVM exception list here
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks002.html
>java \
-Xms2G -Xmx2G -XX:MaxMetaspaceSize=256M \
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="/tmp/dump_oom.hprof" \
-Dbuild.env=${RUNNING_ENV} \
-Drunning_module=${RUNNING_MODULE} \
-jar feeds-2g-1.0-jar-with-dependencies.jar 2>&1
I have my Java application running there for a while day, it is not saying any exception about memory. So that is 90% saying it is not Java OOM, it is use memory over the limit of hard_limit on ECS, and ECS agent killed my Java.
I adjust the configuration according to the ECS document.
http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html
-Xms2G -Xmx2G and hard_limit and soft_limit 3G. Everything looks good after that.
Reference:
https://blogs.vmware.com/apps/2011/06/taking-a-closer-look-at-sizing-the-java-process.html
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks002.html
http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html
Recently, I am working on a Java applications on ECS. It is a docker application running on the cluster.
But it keeps get killed by ECS agent. And the exception is saying, docker application is killed by memory usage.
Does that say my Java application have memory leak and go Out of Memory?
First, I checked my memory configuration on Java level. I am using -Xmx3G. My docker hard_limit and soft_limit are both 3G as well.
I am using spring framework, so I have the Perm Gen 256M.
So the VM may use memory like this: -Xmx3G + Perm Gen 256M + Other memory 217M + Xss per thread(Java Stack) = 3.5G
That might be why the ECS kill my docker applications.
Here are all the JVM exception list here
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks002.html
>java \
-Xms2G -Xmx2G -XX:MaxMetaspaceSize=256M \
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="/tmp/dump_oom.hprof" \
-Dbuild.env=${RUNNING_ENV} \
-Drunning_module=${RUNNING_MODULE} \
-jar feeds-2g-1.0-jar-with-dependencies.jar 2>&1
I have my Java application running there for a while day, it is not saying any exception about memory. So that is 90% saying it is not Java OOM, it is use memory over the limit of hard_limit on ECS, and ECS agent killed my Java.
I adjust the configuration according to the ECS document.
http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html
-Xms2G -Xmx2G and hard_limit and soft_limit 3G. Everything looks good after that.
Reference:
https://blogs.vmware.com/apps/2011/06/taking-a-closer-look-at-sizing-the-java-process.html
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks002.html
http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html

本文讨论了Java应用程序在ECS上运行时遇到的内存限制问题,并详细分析了如何通过调整Java虚拟机参数及Docker配置来解决ECS代理因超出内存限制而终止容器的问题。
1226

被折叠的 条评论
为什么被折叠?



