Page loads very slowly on Dreamhost after some idle time

Hi,

I set up my personal site (todo’s, contacts, etc.) on Dreamhost.
I am the only one who accesses the site.
It’s in production mode and it runs on dispatch.fcgi.

The problem is…

When I visit the site, the first page takes long time (about 30 sec) to
load.
The next page (or the same first page) loads pretty fast once the first
page is loaded.
And if I visit the site after 1 hour, the page takes long time again.

I guess that application is cached but it loses the cache after some
idle time.

How can I narrow down the problem area and fix it?

Thanks.
Sam

On 29 Nov 2007, at 21:27, Sam K. wrote:

Hi,

I set up my personal site (todo’s, contacts, etc.) on Dreamhost.
I am the only one who accesses the site.
It’s in production mode and it runs on dispatch.fcgi.

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

Fred

Hi,

Frederick C. wrote:

On 29 Nov 2007, at 21:27, Sam K. wrote:

Hi,

I set up my personal site (todo’s, contacts, etc.) on Dreamhost.
I am the only one who accesses the site.
It’s in production mode and it runs on dispatch.fcgi.

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

Fred

No. 4 or 5 dispatch.fcgi’s are still there.
However, if I request a page, the dispatch.fcgi’s are replaced with new
one (PID’s are different).

Any idea?

Thanks.

Sam

On 29 Nov 2007, at 21:35, Sam K. 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

Frederick C. wrote:

On 29 Nov 2007, at 21:35, Sam K. 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?

Sam

On 29 Nov 2007, at 21:43, Sam K. wrote:

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 W.

On Nov 29, 4:44 pm, Frederick C. [email protected]

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.

Hi,

HiddenBek wrote:

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 tried the plugin found at
http://gabrito.com/post/ruby-on-rails-dreamhost-plugin and I also failed
to get that to work.

Now I’m testing your plugin and so far so good (for 4 hours now).

With your plugin, have you fixed the problem for sure?

Thanks.

Sam

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.

HiddenBek wrote:

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.

That’s a very good news and I’m relieved.:slight_smile:

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.

It’s so kind of you.

Thank you.

Sam

On Dec 3, 2007 8:09 PM, Sam K. [email protected]
wrote:

I find my site sometimes responds very slowly after hours of inactivity.

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

RailsFCGIHandler.process! nil, 50


Greg D.
http://destiney.com/

Hi HiddenBek,

HiddenBek wrote:

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.

I find my site sometimes responds very slowly after hours of inactivity.
However, the frequency of the occurrence is very low with your
plugin.:slight_smile:

Your cron job hits your site every 5 minutes.
Do you think the cron job keeps the site active all the time and
prevents the slow load?
If that’s the case, the solution would be simple or it might not even be
a problem if visitors kept my site busy.

Any idea?
Unfortunately, I’m not an expert on Linux and Apache.

Thanks.

Sam

Greg D. wrote:

On Dec 3, 2007 8:09 PM, Sam K. [email protected]
wrote:

I find my site sometimes responds very slowly after hours of inactivity.

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

RailsFCGIHandler.process! nil, 50


Greg D.
http://destiney.com/

I just changed it.
I’ll let you know.

Thanks.

Sam

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs