Why does Tomcat opens so many Java Processes for my Application?
grails, java, jvm, spring, tomcat
Solution
What you are probably seeing is threads not processes. According to `man htop` you can hide user threads interactively using the `H` command.
For the record, Tomcat will create a number of worker threads for processing incoming HTTP requests. If you (really) need to control the number of worker threads, there are Tomcat configuration options for doing that.
Problem
I have a Grails 2.2.4 application which is packed as war and deployed to my tomcat7 server on ubuntu 12.04 LTS 64-bit, 8GB RAM. My setenv.sh file contains the following: ``` CATALINA_OPTS=" -server -Xms1G -Xmx2G -XX:MaxPermSize=512m"; ``` I used htop to get the number of running processes. I figured out that there are more than 20 running java processes on my system. Each process of the more than 20 processes looks like this: ``` PRI NI VIRT RES SHR S CPU% MEM* TIME+ Command 20 0 6028M 1290M 11140 S 0.0 16.2 0:01.21 /usr/lib/jvm/java-7-oracle/bin/java -Djava.util.logging.config.file ``` When I stat tomcat with ./bin/startup.sh my application starts without errors. When I access my application with different browsers I get more than 20 Java processes running. The only other Java process I have running is elasticsearch. - Why is tomcat starting so many processes for my application? - Do I have to limit them? If so how?