Tomcat Thread Monitoring Mbeans Description

情到浓时终转凉″ 提交于 2019-12-06 11:48:49

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 by "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 uses java.util.concurrent.ThreadPoolExecutor as a thread pool (default choice), maxThreads maps to the ThreadPoolExecutor's maximumPoolSize, currentThreadsBusy - to activeCount, and currentThreadCount - to poolSize.

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.

You can read about getCurrentThreadCount(), getCurrentThreadsBusy() and maxThreads in JIoEndpoint: Javadoc or Source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!