I have a Java web application running on tomcat 8.5.x on AWS ubuntu ec2 instance.
I was running this application on a m5.xlarge instance which provide 4 vCPU and 16 GB RAM. On this instance my app's CPU usage was around 60% and RAM usage was around 5 GB.
Because RAM usage is quite less, I thought of moving this app to a compute optimized instance to save cost. Hence, I moved it to c5.xlarge instance which provides 4 vCPU and 8 GB RAM. On this instance also my app usage was same around 5 GB RAM usage and 60% CPU. It worked fine for almost 24 hours after which suddenly CPU usage went to 100% and it never went down which resulted in non responsive app.
I tried using m5.large instance as well which provides 8 GB Ram, same issue happened there also, after around 24 hours 100% CPU. Ultimately I moved it back to m5.xlarge instance and it's over 10 days my app is running fine. Usage is also same.
Now I am not able to debug why this 100% CPU usage is happening on a 8 GB instance when my RAM usage is never crossing 5 GB. I have not tuned tomcat for production environment, I am using default settings. Is there any probably cause where I should look into?
/proc/meminfo
and the top few functions on CPU viasudo perf top
. Edit your question to add these details. Quite possible how you've tuned things is falling over at < 8 GB RAM, but prove what is happening with performance metrics.