# Rails on IIS7

**URL:** <https://www.ruby-forum.com/t/rails-on-iis7/117002>\
**Category:** Rails\
**Created:** [October 12, 2007, 12:40am UTC](https://www.ruby-forum.com/t/rails-on-iis7/117002 "2007-10-12T00:40:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Drew](https://www.ruby-forum.com/u/Drew)\
**Post date:** [October 12, 2007, 12:40am UTC](https://www.ruby-forum.com/t/rails-on-iis7/117002/1 "2007-10-12T00:40:46Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Drew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Drew](https://www.ruby-forum.com/u/Drew)\
**Post date:** [October 12, 2007, 4:43am UTC](https://www.ruby-forum.com/t/rails-on-iis7/117002/2 "2007-10-12T04:43:52Z")

</div>

Hi Drew

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

---

<div class="post-metadata">

**Author:** ![Drew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Drew](https://www.ruby-forum.com/u/Drew)\
**Post date:** [October 12, 2007, 4:45am UTC](https://www.ruby-forum.com/t/rails-on-iis7/117002/3 "2007-10-12T04:45:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Drew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Drew](https://www.ruby-forum.com/u/Drew)\
**Post date:** [October 14, 2007, 11:40am UTC](https://www.ruby-forum.com/t/rails-on-iis7/117002/4 "2007-10-14T11:40:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Drew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Drew](https://www.ruby-forum.com/u/Drew)\
**Post date:** [October 17, 2007, 9:40pm UTC](https://www.ruby-forum.com/t/rails-on-iis7/117002/5 "2007-10-17T21:40:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Drew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Drew](https://www.ruby-forum.com/u/Drew)\
**Post date:** [October 15, 2007, 3:34pm UTC](https://www.ruby-forum.com/t/rails-on-iis7/117002/6 "2007-10-15T15:34:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Drew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Drew](https://www.ruby-forum.com/u/Drew)\
**Post date:** [October 18, 2007, 3:22pm UTC](https://www.ruby-forum.com/t/rails-on-iis7/117002/7 "2007-10-18T15:22:50Z")

</div>

Hi Drew

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

---

<div class="post-metadata">

**Author:** ![Drew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Drew](https://www.ruby-forum.com/u/Drew)\
**Post date:** [September 10, 2008, 10:11pm UTC](https://www.ruby-forum.com/t/rails-on-iis7/117002/8 "2008-09-10T22:11:58Z")

</div>

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.
