Tomcat线程监控Mbeans说明
在 Tomcat 的线程相关 Mbean 中,我在 Catalina.ThreadPool 下看到。
有不同的属性,即。 maxThreads、currentThreadCount、currentThreadsBusy 等。
那么,我在哪里可以获得这些 Mbean 属性的描述, 每个属性表示什么,我需要将其包含在我的监控自动化代码中,这将提供线程利用率统计信息。
也可能我想查看源代码,在哪里可以获得它?
当我看到 Mbean 类名(通过 jconsole)时,它显示为 org.apache.tomcat.util.modeler.BaseModelMBean,但是当我查看 BaseModelMBean 的源代码时,我发现没有表示上述这些属性的字段或数据成员此类或其实现的接口的一部分。
那么这里代表的是 Mbean 的哪个实现?
In thread related Mbeans of Tomcat I see under Catalina.ThreadPool.
there are different attributes viz. maxThreads, currentThreadCount, currentThreadsBusy etc.
So, where can I get the description of these Mbean attributes,
what each of these attribute is indicating, I need to include this in my monitoring automation code, Which will provide the Thread utilization stats.
also possible I would like to see the Source code, where can I get it?
When I see the Mbean class name (through jconsole) it shows as org.apache.tomcat.util.modeler.BaseModelMBean, but when I go through the source code of BaseModelMBean I see there are neither fields or data members representing these attributes mentioned above part of this class or the interfaces it implements.
Then which implementation of the Mbean is being represented here??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
maxThreads、currentThreadCount、currentThreadsBusy JMX 属性与 Tomcat 连接器用于处理传入请求的线程池相关。您可以在应用程序线程列表中看到通常名为
http-nio-[port-number]-exec-[sequence-number]
的线程。当请求到达Connector时,Connector通过线程池的方式为其分配某个线程,该线程将处于“忙碌”状态,直到请求被处理。因此,currentThreadsBusy反映了当前正在处理的请求数。
maxThreads 定义在任何情况下都不想超过的线程数。当 currentThreadsBusy 计数器达到 maxThreads 阈值时,无法处理更多请求,并且应用程序会阻塞。
currentThreadCount表示线程池当前拥有的线程数量,包括繁忙的和空闲的,线程池会终止一些线程,如果它们在一段时间内没有使用或创建新的线程,最多达到maxThreads,如果有需求,请参阅下面的详细信息。
“在幕后”,从 Tomcat 7 开始,由
org.apache.tomcat.util.net.AbstractEndpoint
负责线程管理。如果它使用 java.util.concurrent.ThreadPoolExecutor 作为线程池(默认选择),则 maxThreads 映射到 ThreadPoolExecutor 的 maximumPoolSize,currentThreadsBusy - 映射到 activeCount > 和 currentThreadCount - 到poolSize
。话虽如此,currentThreadsBusy 是监控 Web 应用程序运行状况的最佳选择。 maxThreads 更像是一个静态值(除非您随意动态更改它)。 currentThreadCount可能提供一些有用的信息,但有一定的时间延迟。
maxThreads, currentThreadCount, currentThreadsBusy JMX properties relate to a thread pool the Tomcat Connector uses to handle incoming requests. You can see the threads usually named
http-nio-[port-number]-exec-[sequence-number]
in your application thread list.When a request arrives to the Connector, the latter assigns, by the means of a thread pool, a certain thread to it, this thread will be "busy" until the request is handled. So, currentThreadsBusy reflects the number of the requests that are being currently handled.
maxThreads defines the number of the threads you don't want to exceed in any case. When currentThreadsBusy counter reaches maxThreads threshold, no more requests could be handled, and the application chokes.
currentThreadCount indicates the amount of threads the thread pool has right now, both busy and free, thread pool will terminate some threads if they are unused for a certain period of time or create new ones, up to maxThreads, if there is a demand, see the details below.
"Under the hood", since Tomcat 7, it is
org.apache.tomcat.util.net.AbstractEndpoint
that is, among other things, responsible for thread management. If it usesjava.util.concurrent.ThreadPoolExecutor
as a thread pool (default choice), maxThreads maps to the ThreadPoolExecutor'smaximumPoolSize
, currentThreadsBusy - toactiveCount
, and currentThreadCount - topoolSize
.Having said that, currentThreadsBusy is the best choice for monitoring a web application's health. maxThreads is more like a static value (unless you change it dynamically, at will). currentThreadCount may deliver some helpful information, with a certain time lag.
您可以在 JIoEndpoint 中阅读有关 getCurrentThreadCount()、getCurrentThreadsBusy() 和 maxThreads 的信息:
Javadoc
或者
来源
You can read about getCurrentThreadCount(), getCurrentThreadsBusy() and maxThreads in JIoEndpoint:
Javadoc
or
Source