Apache2 reverse proxy seems to intermittently freeze when proxying a tomcat web app.
The problem is that every so often (once or twice a day usually after inactivity) when I try to log into this proxied web application it just freezes. The application just freezes indefinitely, no 500 response code... the browser just waits and waits.
If I keep trying to hint the web address from my browser it will eventually just start working again.
Ive tried to reproduce this issue by navigating directly to the web app on tomcat port 8080, but ive never been able to reproduce this without going through the reverse proxy.
Here is my reverse proxy config... any fault finding ideas? thanks
/etc/apache2/sites-available/default
ProxyPass /manage/ http://localhost:8080/manage/
ProxyPassReverse /manage/ http://localhost:8080/manage/
ProxyPass /manage http://localhost:8080/manage
ProxyPassReverse /manage http://localhost:8080/manage
/etc/apache2/mods-available/proxy.conf
<IfModule mod_proxy.c>
#turning ProxyRequests on and allowing proxying from all may allow
#spammers to use your proxy to send email.
ProxyRequests Off
<Proxy *>
AddDefaultCharset off
Order deny,allow
Deny from all
Allow from all
</Proxy>
# Enable/disable the handling of HTTP/1.1 "Via:" headers.
# ("Full" adds the server version; "Block" removes all outgoing Via: headers)
# Set to one of: Off | On | Full | Block
ProxyVia On
</IfModule>
More info: (not sure if relevant)
- Each web page is averaging 2 - 3 Ajax calls
- Haven't applied 14 Rules for Faster-Loading Web Sites. Looking to apply expires header for caching static content soon.
Enabled apache modules:
core_module (static) log_config_module (static) logio_module (static) mpm_worker_module (static) http_module (static) so_module (static) alias_module (shared) auth_basic_module (shared) authn_file_module (shared) authz_default_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cgid_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) mime_module (shared) negotiation_module (shared) proxy_module (shared) proxy_ajp_module (shared) proxy_connect_module (shared) proxy_http_module (shared) reqtimeout_module (shared) rewrite_module (shared) setenvif_module (shared) status_module (shared)
Update: I am now using the ajp protocol for the proxy. An have set some addition ProxyPass config e.g.
ProxyPass /manage ajp://localhost:8009/manage max=20 ttl=120 acquire=10000 retry=0
ProxyPassReverse /manage ajp://localhost:8009/manage
I would try to use ajp to connect to tomcat from apache.
Please test the configuration using mod_proxy_ajp with Tomcat.
From logs, it looks like the tomcat did not responded to apache's request. It refused the connection.
If you have high traffic, search deeper in your application's logs. It could be a deadlock or maxthreads reached.
HTH
Check that your apache file cache is disabled.
If that doesn't solve the problem (shouldn't, this doesn't seem a cache problem) try debugging using mod_jk. Download appropiate mod_jk version for your Apache, setup it and set the log level to DEBUG
Also, include tons of info in your apache logs
You should now have an Apache log with microseconds taken to serve the page, and a debug-level log of your AJP 1.3 connection to tomcat (with mod_jk).
With that done, restart apache and try forcing that freezing error. When error happens, check time, and browse logs to see what happened in that instant, how much time did apache spend processing, and so.
It won't solve anything, but most possibly will give you some insight on what is happening.
If you are getting a connection refused you may be hitting the maxthread count on Tomcat. What is maxclient set to for Apache? What is maxthread set to on Tomcat? You want to make sure your maxclient doesn't exceed maxthread. If not Apache will attempt to proxy more connection than Tomcat can serve and Tomcat will refuse connections.
Also if you
retry=0
to the end of your ProxyPass statements Apache won't disable the backend worker and your recovery when this problem is encountered will be faster.