Rails on IIS7

The upcoming IIS7 includes out of the box support for FastCGI. I’ve
been trying to get Rails running directly under IIS for the past few
days, and documenting my progress on the wiki:

http://wiki.rubyonrails.org/rails/pages/HowToConfigureIIS7

The problem I have right now is that ruby.exe consistently crashes
after a certain number of requests. The first 3 requests go through.
On the 4th, ruby.exe faults on msvcrt-ruby18.dll and dies. I found
that if I remove the call to prepare_breakpoint in dispatcher.rb, it
will succeed for the first 8 requests, and then fail on the 9th. At
this point, it looks like it’s dying during the call to
write_recognize in routing.rb. The number of requests it takes to fail
is always consistent.

More details and debug traces are on the wiki page, under “ruby.exe
crashing”. Any ideas or direction from Ruby gurus would be greatly
appreciated.

Thanks!
Drew

Hi Drew

I am using ROR and I don’t use IIS.
The recommended approach is Apache2.2x + a pack of mongrels

Hi Drew

I am using ROR in Windows 2003 server but I don’t use IIS.
The recommended approach is Apache2.2x + a pack of mongrels

Hi CCH,

I realize there are lots of easier ways to get Rails working. The goal
is to make this one work. =)

What’s exciting about IIS7/FastCGI is that it makes it plausible to
deploy Rails to an existing, standard Windows server environment,
without a lot of special configuration. I don’t want the server admin
to have to do anything more than run the 1-click Ruby installer. Site
owners can freeze their own copy of Rails, and use web.config files to
configure the FastCGI handler at the site or directory level.

Anyway, I’ve been able to isolate the crashes a bit more. It seems
that garbage collection triggered by fcgi_handler.rb is causing the
problem. Commenting out the GC calls seems to address the issue,
although it’s not a good long-term solution. This is why I was only
seeing the issue with FastCGI. If I add explicit garbage collection to
one of my controllers, WEBrick and Mongrel will crash ruby.exe too.

Windows Vista and Server 2008 have tightened restrictions on memory
management, as a safeguard against buffer overflows and other memory
exploits. Garbage collection works on simple Ruby test scripts, but
not with whatever Rails is passing it.

Are there any instructions around for compiling Ruby on Windows from
source? I think building against the Vista SDK might help.

For anyone interested, this was resolved by compiling FastCGI against
VC6 instead of VC71, to match Ruby and the rest of the extensions
provided with the One-Click Installer. The wiki has been updated with
details.

Drew:

I’ve been working with Rails and IIS for about 2 years. I did some
testing
on the IIS FastCGI stuff back in January. I’ve never run into the
problems
you’re seeing, but I can tell you from experience with Rails that I
would
definitely not recommend deployment of Rails via FastCGI on any system
because of the architectural limitations.

While it’s cool in theory to be able to deploy a Rails app within an
existing IIS infrastructure, Rails apps are not like .Net apps. They are
memory hungry, somewhat intensive processes. Using Apache and mongrels
running as a service allows you to scale to more than one server much
more
easily. This is especially important when you consider the fact that
Ruby
itself runs extremely slow under Windows, often 10 to 20x slower,
depending
on the circumstances.

I’ve submitted a chapter to the book “Deploying Rails Applications”
which
will outline several strategies for deploying on Windows, including one
that
allows you to graft an app onto IIS with ISAPI_Rewrite.

Your theory about recompiling Ruby is interesting… you might send a
message to the Ruby list about that

If you’re interested in further discussion, feel free to contact me.

Hi Drew

Well Done !
I do recall that Ruby fr Windows was compiled under VC6.

Drew wrote:

For anyone interested, this was resolved by compiling FastCGI against
VC6 instead of VC71, to match Ruby and the rest of the extensions
provided with the One-Click Installer. The wiki has been updated with
details.

The link to the binary files is now gone, any clue where we could get
them?

Thanks.