Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find memory usage of web applications in apache tomcat

I'm working on a project where I need to find the memory usage of web applications deployed in Apache tomcat. In an intranet architecture i'd like to develop a tool to find the users accessing the deployed web application and its memory being used. Could someone help me start off with this project. I have configured Apache tomcat and deployed few web applications now. Performance monitoring is the objective of my project. Thank You.

like image 236
Sugosh Ravindra Avatar asked Jan 11 '15 09:01

Sugosh Ravindra


People also ask

How do I check Web application memory usage?

The Task Manager is a realtime monitor that tells you how much memory a page is currently using. Press Shift+Esc or go to the Chrome main menu and select More tools > Task manager to open the Task Manager. Right-click on the table header of the Task Manager and enable JavaScript memory.

How much memory does Tomcat use?

Tomcat will use 2048MB (Xmx parameter) and the size of the heap from version 1.8 is dinamically assigned by JVM. For this configuration your server needs at least >=3.5GB of RAM (It is a good practice always getting 1GB of free RAM for OS).

Where do we define memory for Tomcat?

Navigate to <ApacheInstallDirectory>/bin and open the TomcatXw.exe file. Click the Java tab. Enter the following recommended values: Initial memory pool — 1024 MB.

How do I get Tomcat metrics?

Query Tomcat metrics Tomcat Manager includes access to a JMX proxy servlet with the manager-jmx role, which allows you to query metrics from your web browser. You can find a list of the available MBeans for Tomcat (in plain-text format) at http://localhost:8080/manager/jmxproxy .


2 Answers

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).

like image 73
Petter Nordlander Avatar answered Oct 04 '22 23:10

Petter Nordlander


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.

like image 28
jagb Avatar answered Oct 05 '22 00:10

jagb