本文介绍了配置Apache / Tomcat的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我们正在使用Apache 2.2.3和Tomcat 5使用(在JBoss中4.2.2嵌入式) mod_proxy_jk 作为连接器。

有人可以洒在正确的方法来计算/配置下面的值(以及其他任何可能与此有关)的一些情况。 Apache和Tomcat在不同的机器上运行,并有公羊丰富金额(每4GB)。

相关的server.xml部分:

 <连接器端口=8009
           地址=$ {} jboss.bind.address
           协议=AJP / 1.3
           emptySessionPath =真
           enableLookups =假
           redirectPort =8443
           maxThreads =320
           connectionTimeout =45000
    />

相关httpd.conf文件的部分:

 < IfModule prefork.c>
  StartServers的8
  比MinSpareServers 5
  MaxSpareServers的20
  将ServerLimit 256
  MaxClients的256
  MaxRequestsPerChild 0
< / IfModule>


解决方案

您应该考虑工作量的服务器可能得到的。

最重要的因素可能是同时连接的客户端在高峰时间的数目。尝试确定它和调整的方式设置,其中:


  • 有两个Apache和Tomcat足够的处理线程,他们不需要生成新线程,当服务器负载过重

  • 有没有超过需要,因为它们会浪费资源的服务器的方式更多的处理线程。

通过这种设置可以最大限度地减少服务器的内部维护开销,可能有很大的帮助,尤其是当你的负荷为零星。

例如考虑,你有〜300新请求的应用程序/秒。每个请求平均需要2.5秒即可食用。这意味着,在任何给定时间有需要被同时处理〜750的请求。在这种情况下,你可能要调整你的服务器,这样,他们在启动时〜750的处理线程,你可能想在最大添加类似〜1000的处理线程来处理极高的负荷。

另外考虑到底是什么,你需要一个线程。在previous例如每个请求是独立于其他人,有没有使用会话跟踪。在一个更网络十岁上下的场景,你可能有用户登录到你的网站,并根据您的软件应用,Apache和/或Tomcat可能需要使用同一个线程来服务而来在一个会话的请求。在这种情况下,您可能需要更多的线程。但是我知道Tomcat的,至少,你不会真的需要考虑这个,因为它与线程池的内部工作原理反正。

We are currently using Apache 2.2.3 and Tomcat 5 (Embedded in JBoss 4.2.2) using mod_proxy_jk as the connector.

Can someone shed some light on the the correct way to calculate / configure the values below (as well as anything else that may be relevant). Both Apache and Tomcat are running on separate machines and have copious amounts of ram (4gb each).

Relevant server.xml portions:

<Connector port="8009"
           address="${jboss.bind.address}"
           protocol="AJP/1.3"
           emptySessionPath="true"
           enableLookups="false"
           redirectPort="8443"
           maxThreads="320"
           connectionTimeout="45000"
    />

Relevant httpd.conf portions:

<IfModule prefork.c>
  StartServers       8
  MinSpareServers    5
  MaxSpareServers   20
  ServerLimit      256
  MaxClients       256
  MaxRequestsPerChild  0
</IfModule>
解决方案

You should consider the workload the servers might get.

The most important factor might be the number of simultaneously connected clients at peak times. Try to determine it and tune your settings in a way where:

  • there are enough processing threads in both Apache and Tomcat that they don't need to spawn new threads when the server is heavily loaded
  • there are not way more processing threads in the servers than needed as they would waste resources.

With this kind of setup you can minimize the internal maintenance overhead of the servers, that could help a lot, especially when your load is sporadic.

For example consider an application where you have ~300 new requests/second. Each request requires on average 2.5 seconds to serve. It means that at any given time you have ~750 requests that need to be handled simultaneously. In this situation you probably want to tune your servers so that they have ~750 processing threads at startup and you might want to add something like ~1000 processing threads at maximum to handle extremely high loads.

Also consider for exactly what do you require a thread for. In the previous example each request was independent from the others, there was no session tracking used. In a more "web-ish" scenario you might have users logged in to your website, and depending on your software used, Apache and/or Tomcat might need to use the same thread to serve the requests that come in one session. In this case, you might need more threads. However as I know Tomcat at least, you won't really need to consider this as it works with thread pools internally anyways.

这篇关于配置Apache / Tomcat的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 17:50