Wildfly increasing threads number

888 picture 888 · Mar 3, 2015 · Viewed 8.3k times · Source

I have a Wildfly-8.0.0.Final server running in standalone mode on a Windows machine.

To configure the JVM memory allocation I edited the $JBOSS_HOME\bin\standalone.conf.bat, adding the following:

set "JAVA_OPTS=-Xms512M -Xmx2048M -XX:MaxPermSize=512M"

In the console administration > Runtime > Platform > JVM I noticed that the memory is ok (after some time, it's being released), but the number of threads increases at each client connection.

For the other server configuration I kept the default values.

At the server startup the number of threads is: live 60, daemon 20, but after a few hours I found live 400, daemon 360. I'm not an expert, but this seems to be an error. Is it true? How can I limit the number of threads?

I noticed in console administration Profile > Core > Threads both "Thread Pools" and "Thread Factories" are empty.

Answer

Pau Carre picture Pau Carre · Mar 6, 2015

With the information you provide it's nearly impossible to know what's going on. When you have problems with threads what you should do is profile your application. You could have a thread pool misconfigured causing troubles ( from a Quartz to a database one) which you have no idea about.

  1. IDE Approach

With modern IDEs you should be able to see all the running threads in debug mode. If you can't find a way to start in debug mode your application from the IDE, you could try to use remote debugging.

  1. Thread dump

The JDK has a very nice took called jstack that you can use to get a snapshot of the stack trace for all the threads in a Java application.

  1. Professional Profiler

You can try either JDK's VisualVM or one of the many payed profiles out there. The profiler could give you more information about the threads (when they are created, when they die, how their state changes...)