0

I have a Tomcat 9 server running on my Centos 7.

When I issue the htop command I have a tomcat process which is listed several times and I would like to understand why it appears several times

 PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
   18 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:07.27 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
    1 root       20   0 5517M 1264M 13248 S  0.0 10.9  1:16.08 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   20 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:01.05 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   33 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.25 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   36 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.36 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   17 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:34.36 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   38 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.86 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   21 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.08 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   42 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.70 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   58 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.22 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   13 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.95 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   35 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.39 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   40 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.31 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   34 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.85 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   37 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.37 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   24 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.09 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   10 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:21.94 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   11 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.90 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   12 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.93 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   14 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.01 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   15 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.02 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   16 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.00 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   19 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.06 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   22 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.02 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   23 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.00 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   25 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.06 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   28 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.00 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   29 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.00 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   31 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.04 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   32 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.04 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   39 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.74 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   41 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.25 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   44 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.12 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   45 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.02 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
   46 root       20   0 5517M 1264M 13248 S  0.0 10.9  0:00.00 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

/etc/systemd/system/tomcat.service

[Unit]
Description=Apache Tomcat Web Application Container
Wants=network.target
After=network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el8_0.x86_64/jre

Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx1G -Djava.net.preferIPv4Stack=true'
Environment='JAVA_OPTS=-Djava.awt.headless=true'

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
SuccessExitStatus=143

User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target

Enable Tomcat service to autostart on system start.

systemctl enable tomcat
  • how are you starting your tomcat? – BANJOSA Jan 31 '20 at 10:47
  • @BANJOSA I updated my post. – Aaron Guilbot Jan 31 '20 at 11:31
2

You might want to check the content the following file in your tomcat home: $CATALINA_HOME/conf/server.xml (just do a locate server.xml if you're not sure where it is) and check the maxThreads and minSpareThreads settings in your file.

Basically it's mostly used in heavy load/high concurrent users - tomcat setups. The setting is just to tell tomcat the minimum and maximum of threads it needs/can spawn to handle the http requests.

hope this answers your question

  • <!-- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/> --> These lines are commented in my file – Aaron Guilbot Feb 3 '20 at 14:38
  • And there are no other xml's in your $CATALINA_HOME/conf/ directory overwriting this or having other "service"-tags launching separate services? Can you check tomcat only listens on 1 port (ss -pln | grep java) should give you the output which ports java (and thus also tomcat) is using. – timmeyh Feb 3 '20 at 15:44
  • 1
    The default value is 10 for minSpareThreads and 200 for maxThreads per Connector element (cf. Tomcat's configuration), i.e. every Connector has an implicit <Executor> with those values. @timmeyh, there is a typo in your answer: minThreads instead of minSpareThreads. – Piotr P. Karwasz Feb 3 '20 at 18:32
  • @PiotrP.Karwasz Thanks for your input, I forgot the default values since I mostly explicitly declare them :) The minSpareThreads is Aarons typo in his comment btw. – timmeyh Feb 4 '20 at 7:55
  • @timmeyh, minSpareThreads is the correct one. – Piotr P. Karwasz Feb 4 '20 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.