# Apache Tomcat - Performance Issue (CPU Usage at 98%!)

**URL:** <https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718>\
**Category:** Help / Discuss\
**Created:** [May 9, 2021, 2:11pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718 "2021-05-09T14:11:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![laurin1](https://forum.xwiki.org/user_avatar/forum.xwiki.org/laurin1/32/9_2.png) [@laurin1](https://forum.xwiki.org/u/laurin1)\
**Post date:** [May 9, 2021, 2:11pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/1 "2021-05-09T14:11:55Z")

</div>

Since 13.2, we have had a performance issue. Twice now I’ve found tomcat9.exe process using more than 50% CPU on this server. Right now, it’s using \>97% CPU continuously. The only thing that has changed is the upgrade to 13.2 (actually now we are on 13.3). If I restart the service, the CPU usage returns to normal, but then it starts again at some point. I am going to try to add some monitoring to determine the timing of this issue.

![image](https://forum.xwiki.org/uploads/default/original/2X/b/bad2149ab8f3808181e000cc57db77816595a421.png)

---

<div class="post-metadata">

**Author:** ![laurin1](https://forum.xwiki.org/user_avatar/forum.xwiki.org/laurin1/32/9_2.png) [@laurin1](https://forum.xwiki.org/u/laurin1)\
**Post date:** [May 19, 2021, 4:07pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/2 "2021-05-19T16:07:59Z")

</div>

Ugh, still happening and I’m guessing nobody has any feedback on what could be the cause here.

---

<div class="post-metadata">

**Author:** ![laurin1](https://forum.xwiki.org/user_avatar/forum.xwiki.org/laurin1/32/9_2.png) [@laurin1](https://forum.xwiki.org/u/laurin1)\
**Post date:** [May 19, 2021, 4:12pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/3 "2021-05-19T16:12:30Z")

</div>

Today, even after a restart of the service, still happening. This will make the system unusable for us - that servers is not dedicated to XWiki and we can’t have it overloaded like this!

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [May 19, 2021, 4:20pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/4 "2021-05-19T16:20:59Z")

</div>

Taking resource right after a restart is expected since there is various things to initialize or to cache during first requests.

It would be interesting to take a thread dump when this happens long after a restart when you did not really start something you know to be resource consuming. It should at least tell us what’s running which might give us a clue of what might cause this.

---

<div class="post-metadata">

**Author:** ![slauriere](https://forum.xwiki.org/user_avatar/forum.xwiki.org/slauriere/32/4425_2.png) [@slauriere](https://forum.xwiki.org/u/slauriere)\
**Post date:** [May 19, 2021, 4:56pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/5 "2021-05-19T16:56:25Z")

</div>

Hi Keith, all, Beside the thread dump mentioned by Thomas, inspecting the ongoing requests with [Glowroot](https://glowroot.org/) can also be very handy. Also, you might find it helpful to possibly install the [Active Jobs Extension](https://extensions.xwiki.org/xwiki/bin/view/Extension/Active%20Jobs%20Application/) for checking which jobs are running in the background?

HTH / cheers

---

<div class="post-metadata">

**Author:** ![laurin1](https://forum.xwiki.org/user_avatar/forum.xwiki.org/laurin1/32/9_2.png) [@laurin1](https://forum.xwiki.org/u/laurin1)\
**Post date:** [May 19, 2021, 5:16pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/6 "2021-05-19T17:16:35Z")

</div>

Thanks, and I’m aware of the high usage right after the restart, however, I’ve watched this process enough (I’m kind of obsessive that way) to know it was longer than normal (but can’t give you a number) - however, in this case, I found out after I posted the above that the service had not restarted…was stuck in “Stopping”. When restarting, takes a very long time for the service to stop, then restart.

---

<div class="post-metadata">

**Author:** ![laurin1](https://forum.xwiki.org/user_avatar/forum.xwiki.org/laurin1/32/9_2.png) [@laurin1](https://forum.xwiki.org/u/laurin1)\
**Post date:** [May 19, 2021, 5:18pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/7 "2021-05-19T17:18:46Z")

</div>

Also, prior to this becoming an issue, it NEVER took 98% to do anything. Maybe 405-50%, but at least twice I’ve seen it stuck at 98% for 10 minutes (probably longer, that is when I took a look at it).

---

<div class="post-metadata">

**Author:** ![laurin1](https://forum.xwiki.org/user_avatar/forum.xwiki.org/laurin1/32/9_2.png) [@laurin1](https://forum.xwiki.org/u/laurin1)\
**Post date:** [May 20, 2021, 1:55pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/8 "2021-05-20T13:55:58Z")

</div>

The problem with any of these solutions is if the CPU usage is at 98%, the server is unusable for its other purposes, and most of the time that is not something we can wait to fix. Happened just now and users were having trouble getting their tasks done that use it, so I had to kill it and restart.

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [May 20, 2021, 2:20pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/9 "2021-05-20T14:20:52Z")

</div>

Well taking a thread dump before killing it should not take long.

---

<div class="post-metadata">

**Author:** ![laurin1](https://forum.xwiki.org/user_avatar/forum.xwiki.org/laurin1/32/9_2.png) [@laurin1](https://forum.xwiki.org/u/laurin1)\
**Post date:** [May 20, 2021, 4:02pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/10 "2021-05-20T16:02:50Z")

</div>

Ok, but although I probably have taken a thread dump at some point in my career, I don’t know how to do that. I can look it up, but if you have any pointers, I would appreciate it.

---

<div class="post-metadata">

**Author:** ![laurin1](https://forum.xwiki.org/user_avatar/forum.xwiki.org/laurin1/32/9_2.png) [@laurin1](https://forum.xwiki.org/u/laurin1)\
**Post date:** [May 20, 2021, 4:04pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/11 "2021-05-20T16:04:22Z")

</div>

As described here?

> **[Generate a Java thread dump on Microsoft Windows - Red Hat Customer Portal](https://access.redhat.com/solutions/19170)**
>
> How to get a thread dump from a Java process running on a Windows machine? Can I get a thread dump/stack trace from a Windows JVM? I need a thread dump from a Windows JVM which was started as a service.

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [May 20, 2021, 4:31pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/12 "2021-05-20T16:31:35Z")

</div>

Yes that’s it. As an alternative if you have Glowroot you can access it in its UI which might be a bit easier unless the JVM is really unusable.

---

<div class="post-metadata">

**Author:** ![laurin1](https://forum.xwiki.org/user_avatar/forum.xwiki.org/laurin1/32/9_2.png) [@laurin1](https://forum.xwiki.org/u/laurin1)\
**Post date:** [May 26, 2021, 11:31am UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/13 "2021-05-26T11:31:16Z")

</div>

Well, these instructions don’t work for Apache Tomcat, as there is no Java process…unless I can do it with the Tomcat9.exe process, I guess I’ll try that.

---

<div class="post-metadata">

**Author:** ![laurin1](https://forum.xwiki.org/user_avatar/forum.xwiki.org/laurin1/32/9_2.png) [@laurin1](https://forum.xwiki.org/u/laurin1)\
**Post date:** [May 26, 2021, 12:01pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/14 "2021-05-26T12:01:34Z")

</div>

I don’t know that this is going to be doable. While Tomcat is using 98% of CPU (which it is right now) very operation that normally takes seconds, takes minutes, completely locks up the UI until it is complete. What should take a few minutes, to get this thread dump, will probably take an hour or two. Maybe if I Was adept at what I am doing here, I could cut that down some, but if I can’t get it in the next 10-15 minutes, I will have to kill it as they access to this server for patients.

---

<div class="post-metadata">

**Author:** ![laurin1](https://forum.xwiki.org/user_avatar/forum.xwiki.org/laurin1/32/9_2.png) [@laurin1](https://forum.xwiki.org/u/laurin1)\
**Post date:** [May 26, 2021, 12:09pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/15 "2021-05-26T12:09:02Z")

</div>

Well, another problem doing this - we use the server version of Java, does not have jstack.

---

<div class="post-metadata">

**Author:** ![laurin1](https://forum.xwiki.org/user_avatar/forum.xwiki.org/laurin1/32/9_2.png) [@laurin1](https://forum.xwiki.org/u/laurin1)\
**Post date:** [May 26, 2021, 12:31pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/16 "2021-05-26T12:31:50Z")

</div>

Tried to load the tools from a JRE, as the docs say I can use jcmd instead of the JRE, but that doesn’t work:

```
C:\Temp>psexec -s c:\java\bin\jcmd 5276 Thread.print>thread_dump_001.log

PsExec v2.33 - Execute processes remotely
Copyright (C) 2001-2021 Mark Russinovich
Sysinternals - www.sysinternals.com

Starting c:\java\bin\jcmd on SERVER06...06...
Error: Could not find or load main class sun.tools.jcmd.JCmd
c:\java\bin\jcmd exited on SERVER06 with error code 1.

```

All the time I could give it, had to kill the process.

---

<div class="post-metadata">

**Author:** ![jwielsch](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jwielsch/32/5294_2.png) [@jwielsch](https://forum.xwiki.org/u/jwielsch)\
**Post date:** [June 1, 2021, 6:54am UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/17 "2021-06-01T06:54:34Z")

</div>

We have something similar lately. Our Wiki 12.10.7 LTS on Apache Tomcat/8.5.39 (Ubuntu), with java 11.0.11+9-Ubuntu-0ubuntu2.18.04 stops working randomly. The Tomcat process is at 99% and we have to restart the tomcat8 process.

I’ll reinstall glowroot sometime soon…

---

<div class="post-metadata">

**Author:** ![jwielsch](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jwielsch/32/5294_2.png) [@jwielsch](https://forum.xwiki.org/u/jwielsch)\
**Post date:** [June 1, 2021, 8:06am UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/18 "2021-06-01T08:06:33Z")

</div>

It died just right after an hour 😕

---

<div class="post-metadata">

**Author:** ![laurin1](https://forum.xwiki.org/user_avatar/forum.xwiki.org/laurin1/32/9_2.png) [@laurin1](https://forum.xwiki.org/u/laurin1)\
**Post date:** [June 1, 2021, 12:46pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/19 "2021-06-01T12:46:28Z")

</div>

Trying to install Glowroot, but I don’t understand how.

[Glowroot](https://glowroot.org/)

> Download and unzip [glowroot-0.13.6-dist.zip](https://github.com/glowroot/glowroot/releases/download/v0.13.6/glowroot-0.13.6-dist.zip), add `-javaagent:path/to/glowroot.jar` to your application’s JVM args

Using Apache Tomcat on Windows, I don’t see how that is possible.

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [June 1, 2021, 12:54pm UTC](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718/20 "2021-06-01T12:54:05Z")

</div>

Hi. I’ve just googled for `apache tomcat windows jvm args` and the first link I got led to  
[Add JVM options in Tomcat - Stack Overflow](https://stackoverflow.com/questions/7738794/add-jvm-options-in-tomcat) which has instructions. I’m sure you can also simply go to the tomcat user guide for windows.

Hope it helps

[Next page](https://forum.xwiki.org/t/apache-tomcat-performance-issue-cpu-usage-at-98/8718.md?page=2)
