Page loads very slowly on Dreamhost after some idle time

Are the dispatch.fcgis dying/getting killed when they are inactive for too long ?

Fred

Well if for whatever reason you end up getting a request server by a new dispatch.fcgi that will slow things down, since booting the rails environment takes some time, and obviously none of your code is cached. This is probably a magic fast-cgi problem. I've moved away from using that a long time ago, so no clue on why this is happening.

Fred

Frederick Cheung wrote:

I am the only one who accesses the site.

new
one (PID's are different).

Well if for whatever reason you end up getting a request server by a
new dispatch.fcgi that will slow things down, since booting the rails
environment takes some time, and obviously none of your code is
cached. This is probably a magic fast-cgi problem. I've moved away
from using that a long time ago, so no clue on why this is happening.

Fred

Thank you for the explanation.
Do you know if there's an alternative to fast-cgi on Dreamhost?

I don't even really know what Dreamhost is, so no.

Fred

are your threads fro dream host falling asleep? I had that issue with
mongrel on ubuntu

White Wizzard

The only alternative that I'm aware of is regular cgi, which is even
slower. Dreamhost greatly oversells their capacity and must kill off
processes constantly to keep resource usage down. The best solution
is to switch to a decent host, but running a cron job that hits your
site every 5 minutes should keep a dispatch.fcgi ready to go most of
the time.

Heavy page caching will make a big difference of course. Cached pages
are served entirely by apache, so Rails environment startup time isn't
a factor. This is a tricky subject though, and probably isn't worth
bothering with just to save a few bucks a month on web hosting.

Dreamhost will happily kill dispatch.fcgi in the middle of a request,
leading to intermittent 500 errors. I wrote a plugin in to correct
this. Install it with:

script/plugin install http://hg.rubyinspace.com/public/plugins/file/tip/impolite_host/

Be sure to look at the README. This plugin interferes with webrick or
mongrel, so it's disabled by default. A small change to dispatch.fcgi
is required to turn it on. This plugin is similar to the dreamhost
plugin found at http://gabrito.com/post/ruby-on-rails-dreamhost-plugin,
but I was unable to get that to work.

Good luck.

I've been running with the plugin for a few weeks now and my cron
script, which hits my site every 5 minutes, 24/7, has only returned an
error twice. I believe both were network issues. Dreamhost has a
bunch of servers however, and I don't think they're all configured the
same way, so your mileage may vary.

This won't do anything about processes killed during idle times, so
you'll still hit occasional slowdowns while rails initializes. If a
dispatch.fcgi is killed in the middle of a request though, it will
wait until the request is served to terminate. It's a very simple
change and should be pretty much foolproof, but feel free to email me
if you run into trouble.

Have you tried forcing more frequent garbage collection? I use this
on one site I run:

RailsFCGIHandler.process! nil, 50