错误的网关502错误与Apache的mod_proxy和Tomcat

问题描述:

我们正在运行在Tomcat 6 Web应用程序和Apache的mod_proxy 2.2.3。看到很多502的错误是这样的:

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 invalid response from an upstream server.

代理服务器无法处理请求GET /the/page.do。

The proxy server could not handle the request GET /the/page.do.

原因:从远程服务器读取错误

Reason: Error reading from remote server

如果您认为这是一个服务器错误,请与网站管理员联系。

If you think this is a server error, please contact the webmaster.

错误502

Tomcat的有很多线程,所以它不是线程限制。我们可以通过JMeter推2400年用户对应用程序。所有的箱子都快速卸载网络上坐在我们的防火墙之内,所以不应该有任何网络问题。

Tomcat has plenty of threads, so it's not thread-constrained. We're pushing 2400 users via JMeter against the app. All the boxes are sitting inside our firewall on a fast unloaded network, so there shouldn't be any network problems.

任何人有任何建议的东西来看待,或者尝试?我们要去旁边和tcpdump。

Anyone have any suggestions for things to look at or try? We're heading to tcpdump next.

更新08年10月21日:仍然没有想通了这一点。只看到负载下极少数的这些。下面这些问题的答案没有提供任何神奇的答案...但。 :)

UPDATE 10/21/08: Still haven't figured this out. Seeing only a very small number of these under load. The answers below haven't provided any magical answers...yet. :)

所以,在这里回答我的问题。我们最终确定,我们看到在负载平衡器502和503的错误是由于Tomcat的线程超时。在短期内,我们增加了超时。从长远来看,我们修复了被摆在首位造成超时的应用问题。为什么Tomcat的超时正在视为502,并在负载平衡器503错误仍然是一个有点神秘。

So, answering my own question here. We ultimately determined that we were seeing 502 and 503 errors in the load balancer due to Tomcat threads timing out. In the short term we increased the timeout. In the longer term, we fixed the app problems that were causing the timeouts in the first place. Why Tomcat timeouts were being perceived as 502 and 503 errors at the load balancer is still a bit of a mystery.