如何在Tomcat中查找Web应用程序的内存使用情况

如何在Tomcat中查找Web应用程序的内存使用情况

问题描述:

我正在一个项目中,我需要查找部署在Apache tomcat中的Web应用程序的内存使用情况.在Intranet体系结构中,我想开发一种工具来查找正在访问已部署的Web应用程序及其内存使用情况的用户.有人可以帮我开始这个项目.我已经配置了Apache tomcat,现在部署了一些Web应用程序.绩效监控是我项目的目标. 谢谢.

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.

您可以使用JMX轻松访问Tomcat JVM的内存使用情况.有关更多信息,请参见此 SO .请注意,您将获得tomcat +所有已部署的Web应用程序的内存使用情况.您无法获得单个Web应用程序的内存使用情况,因为Tomcat为容器和应用程序共享一个Java进程.如果您想更好地控制每个应用程序的内存使用量,建议您要么使用更复杂的应用程序服务器,要么为每个Web应用程序使用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.

要监视已连接的用户,我想您必须在应用程序层上执行某些操作. Tomcat并没有真正意识到用户"的概念,因为这通常是您在代码中实现的(例如Spring Security).

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