Topic: Bad Gateway errors, mongrel + apache 2.2 + mod_proxy_balancer

My rails app running on apache2.2 + mod_proxy_balancer + mongrel is very problematic.  It seems to work, but then I will get Bad Gateway errors.

Bad Gateway

The proxy server received an invalid response from an upstream server.

Apache/2.2.4 (EL4) Server at rori.uchicago.edu Port 443

I have not changed anything in the config, these errors seem to happen at least once a day.  I have to restart mongrel_rails and apache every time these occur.

I looked in the mongrel faq - my database is mysql.  I have tried setting the mysql timeout in environments.rb.  This did not fix the problem.  The apache logs are no help - they just tell me that I got a 502 error at a certain time.  My mongrel log gives me a message like

  Parameters: {"action"=>"action", "controller"=>"controller"}
Filter chain halted as [#<Proc:0xb78cf05c@/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:597>] did not yield.
Completed in 0.01867 (53 reqs/sec) | Rendering: 0.00009 (0%) | DB: 0.00000 (0%) | 401 Unauthorized [http://domain.com/xxx/xxx]


I am not sure why this app is behaving so erratically.  Could the 401 messages have anything to do with it?  I do not get these messages during the time when the app is behaving correctly.

14) [GET]
  Session ID: 4caad9c75554b858b1a6d9d421fdc76c
  Parameters: {"action"=>"action", "controller"=>"controller"}
Rendering  within layouts/controller
Rendering controller/action
Completed in 0.00486 (205 reqs/sec) | Rendering: 0.00249 (51%) | DB: 0.00200 (41%) | 200 OK [https://domain.com/controller/action]

the above are production.log messages when the app is behaving correctly.

Any help appreciated.  Thanks.