Standalone tomcat 9 spikes CPU to 50% every 10 seconds while my web application is idle

3.1k Views Asked by At

I am using Tomcat 9.0.0.M22 with jdk1.8.0_131 on Windows Server 2012 R2 and I have a Spring Boot web application deployed on it, the issue is that every 10 seconds the commons daemon service runner spikes the cpu to 50% although my deployed web application is idle then decreases to 0% and this behavior continue to happen every 10 seconds.

In my application I don't have any job that runs every 10 seconds, and also when I run my web application on Tomcat from Eclipse I didn't notice the same behavior, so I am guessing that this is a Tomcat built in thread.

4

There are 4 best solutions below

0
On
  • do a series of thread dumps as soon as cpu load spikes
  • you can use jdk/bin/jvisualvm to connect to your tomcat and repeatedly press thread dump button on upper right of threads tab or if you prefer command line (e.g. via script), you can also use jdk/bin/jcmd <pid-of-your-tomcat> Thread.Print >> dumps.txt
  • each dump shows all threads existing at that moment and a stack trace for each thread showing what is being executed
  • this should give you some hints what's involved creating that load
0
On

Without more information this is just guessing but this could be the garbage collector trying to do it's job every ten seconds but not being able to evict any items because they are all still needed. You could try to increase the memory for Tomcat (-Xmx).

0
On

With that much info it's pretty tough, couple of points you can think of:

  • As @jorg pointed out, you can take thread dumps that will give you insights about any blocking threads.
  • You said it's working fine on local system, it doesn't necessarily mean that code is optimal for the server platform. Double check configurations, maxThreads etc.
  • Optimize Server JVM by eliminating any excessive garbage collection. Starting the JVM with a higher maximum heap memory (-Xmx) will decrease the frequency with which garbage collection occurs.
  • Existing monitoring tools can leverage your analysis (jVisualVM) .
0
On

I was able to stop this behavior completely by setting reloadable="false" in context.xml.