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 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.
//Nothing related to the answer. This text is added to get over the validation of stackoverflow that edit should be at least 6 characters which is not always the case, particularly for answers related computer programming. SFO should reconsider this validation.
^ agree with the above and thanks for editing. igor.zh.