How to find memory usage of web applications in apache tomcat How to find memory usage of web applications in apache tomcat apache apache

How to find memory usage of web applications in apache tomcat


You can access the memory usage for the Tomcat JVM using JMX pretty easy. See this SO for more info. Please note that you will get memory usage for tomcat + all deployed web apps. You cannot get memory usage for a single webapp, since Tomcat share a single java process for both container and apps. If you want better control over memory usage per app, I suggest you either use a more sophisticated application server or use a tomcat instance per webapp.

To monitor connected users, I guess you have to do something on the application layer. Tomcat is not really aware of the concept of "user", since that is typically something you implement in the code (like Spring Security).


Did you read this? You can't, please read http://wiki.apache.org/tomcat/FAQ/Memory (archive.org copy) too:

You can't find out how much memory a web application is using. The JVM doesn't give us these detail or information.


I would recommend glowroot a very good open source Java application performance monitoring (APM) tool that you can attach to Tomcat without change any java source code.

To use it just need download it and add on the start of your JVM-javaagent:path/to/glowroot.jar

For tomcat you need to add the environment variable

JAVA_OPTS="$JAVA_OPTS -javaagent:path/to/glowroot.jar"on /etc/tomcat8/tomcat8.conf

For more details see instructions on project github

It has very light overhead that you could use temporary in production to extract several application performance information and tested with Tomcat.

You can see a demo of gauges from JVM and histogram of the heap memory here