问题
My server.xml looks like the following:
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<Executor name="tomcatThreadPool"
namePrefix="catalina-exec-"
maxThreads="200"
minSpareThreads="4"/>
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="10000"
maxKeepAliveRequests="1"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
However, in the Tomcat manager (http://localhost/manager/status) it shows to following
http-8080: Max threads: -1 Current thread count: -1 Current thread busy: -1
jk-8009: Max threads: 200 Current thread count: 4 Current thread busy: 1
For some reason it looks like http-8080 isn't using the executor even though it is directed too and jk-8009 is using the executor even though it isn't instructed to. Is the manager just misreporting or have I not setup the thread pool correctly?
回答1:
My guess is that the manager is reporting the values that were set as part of the connector defintions, and not reporting the values from the executor. The executor wil work as expected, it's just not reported correctly in the manager.
The 200 value for the AJP connector is misleading here, since 200 is the default value for maxThreads
(as defined here); because you didn't specify maxThreads
for the AJP connector, this is the value that is used.
The HTTP connector is reporting nonsense values because it's delegating its thread management to the executor.
To check if this is all true, try changing the maxThreads
value of the executor to a different value. You should see maxThreads
of the AJP connector staying at 200 (because that's its default value).
回答2:
The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool. Note that if an executor is configured any value set for this attribute will be recorded correctly but it will be reported (e.g. via JMX) as -1 to make clear that it is not used.
来源:https://stackoverflow.com/questions/2761618/why-is-my-tomcat-6-executor-thread-pool-not-being-used-by-the-connector