简体   繁体   English

Apache + Tomcat部署中Tomcat线程池的行为

[英]Behavior of Tomcat Thread Pool in Apache + Tomcat Deployement

I have deployed a popular web application benchmark called TPC-W in a 3 tier setting. 我已经在3层环境中部署了一个流行的Web应用程序基准测试,称为TPC-W。 I have two physical nodes, one running Apache Web Server and another running Tomcat + MySQL. 我有两个物理节点,一个运行Apache Web Server,另一个运行Tomcat + MySQL。 I'm using a shared executor in Tomcat and I'm trying to understand it's behavior. 我在Tomcat中使用共享的执行程序,并且试图了解它的行为。 I'm using JMX to monitor the Tomcat JVM. 我正在使用JMX监视Tomcat JVM。

Here's my question. 这是我的问题。 The completedTaskCount attribute of the Tomcat shared executor MBean does not update according to the number of served requests (actually it keeps unchanged at 0). Tomcat共享执行器MBean的completedTaskCount属性不会根据提供的请求数进行更新(实际上,它保持不变为0)。 I can see that there's a very large number of requests served under AJP-connector in GlobalRequestProcessor MBean. 我可以看到,GlobalRequestProcessor MBean中的AJP连接器下有很多请求。 Why is that? 这是为什么? Shouldn't completedTaskCount increment as requests are processed. 在处理请求时,不应completedTaskCount TaskCount增量。

The only possible explanation I could come with is that this is because of some behavior in the AJP protocol. 我唯一可能给出的解释是,这是由于AJP协议中的某些行为所致。 I assumed that for whatever the reason, each Apache process gets connected to a thread in the Tomcat executor thread pool and sends all incoming requests as a single request to the Apache. 我假设无论出于何种原因,每个Apache进程都连接到Tomcat执行程序线程池中的一个线程,并将所有传入请求作为单个请求发送到Apache。 Even any new incoming request is sent as a part of that request. 甚至任何新的传入请求都作为该请求的一部分发送。 in that case, the Tomcat thread would never see as that request from Apache is fully served. 在这种情况下,Tomcat线程将永远无法看到,因为来自Apache的请求已完全得到满足。 Does this make any sense? 这有道理吗?

Any pointers or help regarding this is highly appreciated. 对此的任何指示或帮助都将受到高度赞赏。

Edit 1 编辑1

Tomcat Version: 7.0.94 Tomcat版本:7.0.94

Apache Version: 2.4.38 Apache版本:2.4.38

This is the connector definition: 这是连接器定义:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" executor="tomcatThreadPool"/>

Here is the shared executor definition: 这是共享的执行程序定义:

<Executor name="tomcatThreadPool" namePrefix="tpcw-exec-" maxThreads="200" minSpareThreads="25"/>

AJP uses keep-alive connections by default. 默认情况下,AJP使用保持活动连接。 BIO connections have a thread allocated to them when the are opened and that thread stays allocated until the connection closes. 当打开BIO连接时,会为其分配一个线程,并且该线程将保持分配状态,直到连接关闭。

The use of keep-alive connections means the connection never closes so the thread never returns to the pool so the Executor never sees a completed task. 使用保持活动连接意味着连接永远不会关闭,因此线程永远不会返回到池,因此执行程序永远不会看到完成的任务。 If you bounce one of the httpd instances that should close the open connections and you should see the completed task count on the executor rise - but only by the number of connections, not the number of processed requests since each connection processes many requests. 如果您跳出应该关闭打开的连接的httpd实例之一,并且您应该看到执行程序执行的任务数增加-但这仅取决于连接数,而不是已处理请求数,因为每个连接都处理许多请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM