what causes 504 Gateway Time-out in mod_jk with tomcat7 & apache2?

可紊 提交于 2019-12-11 04:37:08

问题


I'm running tomcat 7 with apache 2.2 & mod_jk 1.2.26 on a debian-lenny x64 server with 2GB of RAM, 8GB of swap & an Intel Xeon CPU X3330. I've a GWT application which uses connection pooling to interact with backend mysql database. this application have to process many request, but each request takes a little time to process (assume 1 second) & then it must free's the allocated resources for using by the other requests. The number of concurrent clients may increase more than 200 at the pick time, but usually is less than 100.
Apache is configured in prefork-mpm mode with this configurations:

<IfModule mpm_prefork_module>
    StartServers       8
    MinSpareServers    5
    MaxSpareServers   20
    MaxClients       256
    MaxRequestsPerChild  2000
</IfModule>

& this is my worker.properties file:

worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

worker.worker1.lbfactor=1
worker.worker1.connect_timeout=6000
worker.worker1.prepost_timeout=6000
worker.worker1.connection_pool_size=256
worker.worker1.connection_pool_minsize=64
worker.worker1.connection_pool_timeout=60
worker.worker1.reply_timeout=1000
worker.worker1.retries=5

worker.worker1.fail_on_status=-500

worker.worker1.cachesize=64
worker.worker1.cache_timeout=60

& this is configuration of tomcat connector in server.xml:

 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"  connectionTimeout="60000" maxThreads="256" acceptorThreadCount="2" />

Now, the problem is that some of my application requests fail with a 504 gateway time-out error. I've changed & tested many settings is all above configuration files, but I could not gain a stable state. In addition, after some hours of running tomcat, many of running application on the server crashes with an error related to fork new processes & leak of system resources (I'm running on a VPS but I'm sure that I have enough resources & even more than I need to run such application & so I'm sure the problem is just because of bad configurations of apache, tomcat & mod_jk).
Any idea? please suggest an ideal configuration for mpm_prefork, mod_jk worker properties & tomcat connector settings with care to this spacial situation (I mean exactly we have an ajax application which process many short-time requests of many users).
Thanks

来源:https://stackoverflow.com/questions/13207633/what-causes-504-gateway-time-out-in-mod-jk-with-tomcat7-apache2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!