We\'re running a web app on Tomcat 6 and Apache mod_proxy 2.2.3. Seeing a lot of 502 errors like this:
Bad Gateway! The proxy server received an in
If you want to handle your webapp's timeout with an apache load balancer, you first have to understand the different meaning of timeout.
I try to condense the discussion I found here: http://apache-http-server.18135.x6.nabble.com/mod-proxy-When-does-a-backend-be-considered-as-failed-td5031316.html :
It appears that
mod_proxyconsiders a backend as failed only when the transport layer connection to that backend fails. Unlessfailonstatus/failontimeoutis used. ...
So, setting failontimeout is necessary for apache to consider a timeout of the webapp (e.g. served by tomcat) as a fail (and consecutively switch to the hot spare server). For the proper configuration, note the following misconfiguration:
ProxyPass / balancer://localbalance/ failontimeout=on timeout=10 failonstatus=50
This is a misconfiguration because:
You are defining a
balancerhere, so thetimeoutparameter relates to thebalancer(like the two others). However for abalancer, thetimeoutparameter is not a connection timeout (like the one used withBalancerMember), but the maximum time to wait for a free worker/member (e.g. when all the workers are busy or in error state, the default being to not wait).
So, a proper configuration is done like this
timeout at the BalanceMember level:
BalancerMember http://member1:8080/svc timeout=6
... more BalanceMembers here
failontimeout on the balancerProxyPass /svc balancer://mycluster failontimeout=on
Restart apache.