apache hangs when tomcat fails-Collection of common programming errors
I have apache in front of Tomcat, using mod_rewrite
and mod_proxy
to relay requests while serving static content directly.
The Tomcat server can get bogged down and stop responding, or just plain crash. My problem is that in those cases it takes the apache httpd down with it. And it won’t come back up even after I set Tomcat straight.
When this happens, the only way to get apache working again is to issue a stop command, then kill -9
remaining apache processes, and lately I also had to run ipcrm
to remove semaphores, otherwise I get a “No space left on device” error.
My guess is that all of apache’s workers become proxy threads, waiting to time out, while nothing else is being served.
I don’t want to change the ProxyTimeout
, because during normal operation, some requests can really take a long time. But I would like a way to tell apache to stop all the waiting proxy requests it has right now and start afresh.
Is there such a thing, or is there another way I should approach this?
I’m using ubuntu 8.04.
-
You could try using mod_jk rather than mod_proxy. mod_jk allows you to configure a maximum number of connections to your tomcat. In your workers.properties file use:
worker.worker_name.connection_pool_size = 10
The value you use should be lower than the maximum number of connections in your Apache configuration. Hopefully, what should happen is that once that number of connections are waiting for tomcat, any more requests will return a 500 error, but you’d still have threads left to serve other requests.
There is a note saying that if you’re using the prefork MPM, then you shouldn’t set this value to higher than one, so this will only work if you’re using the threaded MPM.