java 为什么连接器没有使用我的 Tomcat 6 执行程序线程池?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2761618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 22:42:22  来源:igfitidea点击:

Why is my Tomcat 6 executor thread pool not being used by the connector?

javatomcattomcat6server.xml

提问by jwegan

My server.xml looks like the following:

我的 server.xml 如下所示:

<!--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

但是,在 Tomcat 管理器(http://localhost/manager/status)中,它显示如下

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?

出于某种原因,看起来 http-8080 没有使用执行程序,即使它也被定向,而 jk-8009 正在使用执行程序,即使它没有被指示。经理只是误报还是我没有正确设置线程池?

回答by skaffman

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 maxThreadsfor the AJP connector, this is the value that is used.

用于AJP连接的200值是误导这里,由于200是作为默认值maxThreads(如定义在这里); 因为您没有maxThreads为 AJP 连接器指定,所以这是使用的值。

The HTTP connector is reporting nonsense values because it's delegating its thread management to the executor.

HTTP 连接器报告无意义的值,因为它将其线程管理委托给执行程序。

To check if this is all true, try changing the maxThreadsvalue of the executor to a different value. You should see maxThreadsof the AJP connector staying at 200 (because that's its default value).

要检查这是否全部正确,请尝试maxThreads将 executor的值更改为不同的值。您应该看到maxThreadsAJP 连接器保持在 200(因为这是它的默认值)。

回答by Rahul

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.

此连接器要创建的最大请求处理线程数,因此决定了可以处理的最大并发请求数。如果未指定,则此属性设置为 200。如果执行程序与此连接器关联,则忽略此属性,因为连接器将使用执行程序而不是内部线程池执行任务。请注意,如果配置了执行程序,则为此属性设置的任何值都将被正确记录,但将报告(例如,通过 JMX)为 -1,以表明它未被使用。