Forum: Ruby on Rails Windows Production Apache Cluster. Mongrel sleeps

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6084ba186cb1b878a8eeee509ddaf71f?d=identicon&s=25 Chris Dekker (chrisdekker)
on 2009-03-30 15:13
When running production mode on Windows 2003 using Apache and a proxy
balancer mod and mod_rewrite to redirect to the mongrel instances, I
sometimes get a Proxy Error thrown from Apache.

Setup is done according to this guide:
http://nlakkakula.wordpress.com/2008/11/24/10-step...

4 Mongrel processes run as Windows Services on high ports (4000+)

VHost entry:

<Proxy balancer://ruby_cluster>
  BalancerMember http://127.0.0.1:4004
  BalancerMember http://127.0.0.1:4005
  BalancerMember http://127.0.0.1:4006
  BalancerMember http://127.0.0.1:4007
</Proxy>

<VirtualHost *:80>
  ServerName ************
  DocumentRoot C:/websites/***********/

  <Directory C:/websites/**********/public/ >
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

  ErrorLog C:/websites/**********/log/apache_error.log
  LogLevel warn

  CustomLog C:/websites/**********/log/apache_access.log combined

  RewriteEngine On

  # Check for maintenance file and redirect all requests
  RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteRule ^.*$ /system/maintenance.html [L]

  # Rewrite index to check for static
  RewriteRule ^/$ /index.html [QSA]

  # Rewrite to check for Rails cached page
  RewriteRule ^([^.]+)$ $1.html [QSA]

  # Redirect all non-static requests to cluster
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://ruby_cluster%{REQUEST_URI} [P,QSA,L]
</VirtualHost>


Now this all works fine. Apache gets hit on port 80 like normal and
redirects its request to one of the 4 mongrel services which will render
the appropriate response.

However when the website hasn't seen traffic in a long while, lets say
roughly 24 hours, the first hit always results in a 502 Proxy Error from
apache:


Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /.

Reason: Error reading from remote server


Refreshing the page will display the ruby generated page correctly
again.

It seems that Mongrel falls asleep or something like that and will react
either too late or with an invalid response when queried by Apache.

Does anyone have any advice on how to counter this problem?
6084ba186cb1b878a8eeee509ddaf71f?d=identicon&s=25 Chris Dekker (chrisdekker)
on 2009-04-01 18:57
Anyone got any idea on how to tackle this problem?
This topic is locked and can not be replied to.