Apache, Rails, FastCGI, Ruby, slow

I’m running Windows XP Pro on a not-so-new machine, Pentium 4 2.4GHz
with 512 RAM. I’ve got Apache 2 installed and I’m using FastCGI to run
Typo in development mode while I design a theme for it. But it’s slow,
very slow.

Inconsistently slow. If I reload a page, sometimes it happens pretty
quickly. Sometimes it takes more than a minute. Sometimes it gives me
an error message where the app doesn’t load at all. Sometiems I get the
page but without any CSS applied to it (even though reloading it works
fine.)

I had to firstly limit the number of running ruby.exe processes. Before
I configured it to use a maximum of 1, whenever I tried to run Typo a
seemingly endless number of ruby.exe would start; so many that
eventually my computer would crash unless I quickly ran into Task
Manager and shut every instance down. Despite the number of ruby.exe
processes that were running, Typo was still slow. Ruby.exe itself takes
up 25-40MB of RAM at any given moment which I find to be massive.

I’m using the Typo trunk as it’s the only version that works with 1.1.

What is going on here? Surely I don’t want my hosting to be like this,
slow and RAM-devouring. A PHP blog script certainly doesn’t use this
many resources, does it?

Eleo wrote:

I’m running Windows XP Pro on a not-so-new machine, Pentium 4 2.4GHz
with 512 RAM. I’ve got Apache 2 installed and I’m using FastCGI to run
Typo in development mode while I design a theme for it. But it’s slow,
very slow.

Inconsistently slow. If I reload a page, sometimes it happens pretty
quickly. Sometimes it takes more than a minute. Sometimes it gives me
an error message where the app doesn’t load at all. Sometiems I get the
page but without any CSS applied to it (even though reloading it works
fine.)

I had to firstly limit the number of running ruby.exe processes. Before
I configured it to use a maximum of 1, whenever I tried to run Typo a
seemingly endless number of ruby.exe would start; so many that
eventually my computer would crash unless I quickly ran into Task
Manager and shut every instance down. Despite the number of ruby.exe
processes that were running, Typo was still slow. Ruby.exe itself takes
up 25-40MB of RAM at any given moment which I find to be massive.

I’m using the Typo trunk as it’s the only version that works with 1.1.

What is going on here? Surely I don’t want my hosting to be like this,
slow and RAM-devouring. A PHP blog script certainly doesn’t use this
many resources, does it?

512MB is not enough on Windows XP. Even with no applications running it
will commit 600MB or more. With MySQL, Apache, Ruby, Rails etc it will
commit around 800MB. 25MB per ruby server is about.

I’d recomend no less than 1GB of ram on Windows, but 512MB could provide
you with gobs of extra memory in Linux :wink:

Beyond that…

Configure Apache to run with a small number (maybe 2?) of static fastcgi
servers instead of running them dynamically. It’s most likely the
dynamic servers having to startup that you are noticing. When it takes
to long Apache can time out.

First of all, are you clear on why you’re using Apache+FCGI for
development? WEBrick should be fine unless you’re in the tiny minority
writing code that needs Apache specifically (e.g. crazy stunt
programming somehow mixing PHP or mod_perl and Rails, or testing some
convoluted single-sign-on shared with other non-Rails apps on the same
Apache).

If this is not the case, lightpd is going to have much less overhead
than Apache if you’re adamant about running FCGI on your development box
(why?!), but WEBrick really is all you need and you’ll drop RAM
utilization enormously.

Assuming you need to develop against Apache for the reasons above, 512MB
is going to be borderline but might be doable. The problem you seem to
be having is FastCGI spawining too many processes. If you’re seeing more
than three or four at a time, that’s your problem. You should be
configured to spawn one, maybe two.

Can we see the blocks of your Apache config related to FCGI and your
Rails app? The entire FastCGI config block and the VirtualHost block or
.htaccess should do it.

Eleo wrote:

I’m running Windows XP Pro on a not-so-new machine, Pentium 4 2.4GHz
with 512 RAM. I’ve got Apache 2 installed and I’m using FastCGI to run
Typo in development mode while I design a theme for it. But it’s slow,
very slow.

Inconsistently slow. If I reload a page, sometimes it happens pretty
quickly. Sometimes it takes more than a minute. Sometimes it gives me
an error message where the app doesn’t load at all. Sometiems I get the
page but without any CSS applied to it (even though reloading it works
fine.)

I had to firstly limit the number of running ruby.exe processes. Before
I configured it to use a maximum of 1, whenever I tried to run Typo a
seemingly endless number of ruby.exe would start; so many that
eventually my computer would crash unless I quickly ran into Task
Manager and shut every instance down. Despite the number of ruby.exe
processes that were running, Typo was still slow. Ruby.exe itself takes
up 25-40MB of RAM at any given moment which I find to be massive.

I’m using the Typo trunk as it’s the only version that works with 1.1.

What is going on here? Surely I don’t want my hosting to be like this,
slow and RAM-devouring. A PHP blog script certainly doesn’t use this
many resources, does it?

I noticed this too but it’s completely resolved if you can get into
production mode. The other option seems to be running it without sIFR
to render the fonts until you’re ready for production mode.

Works very well for me on my mac mini and on our managed server. In
dev mode even the 2 cpu server with 2GB ram was using 100% cpu (on one
of the cpus). In production it’s perfectly quiet.

-Chuck

Michael G. wrote:

512MB is not enough on Windows XP.
Ideally, no. But I’d have to disagree. This computer and even earlier
computers shipped with the OS; I find it illogical that it’s “not
enough”. On the contrary it’s been adequate for a few years now but
certainly needs to be replaced.

Actually the only reason why I installed Apache/FastCGI is for figuring
out how to properly set it up. You see my friend has a shared server
and is hosting me but isn’t totally adept on how to run his server
besides handing out an account with cpanel. He has yet to figure out
how to give me superuser privileges so I can install software for myself
(even I don’t know how to do this), so I frequently have to walk him
through the installation and configuration of things for Rails. Most
recently he installed ruby and rails on the server but I realized I had
to use Webrick which seemed inadequate for an actual site. My
installation of Apache/FastCGI was merely to become familiar with it.
Had I known that it could use so many resources I would have never tried
to stick with it. I do find it more convenient than keeping a command
prompt window open.

Eleo wrote:

Michael G. wrote:

512MB is not enough on Windows XP.
Ideally, no. But I’d have to disagree. This computer and even earlier
computers shipped with the OS; I find it illogical that it’s “not
enough”. On the contrary it’s been adequate for a few years now but
certainly needs to be replaced.

According to Microsoft 128MB is minimum required memory… lots of fun
trying to run anything in that. The fact that it shipped with 512
doesn’t mean anything. Even with nothing running XP will commit 600+
MB. This means that you run the risk of a page swaps at any time.

It will run, it doesn’t run well.