Home MVC Storefront

Rails for IIS: Always Have Friend Named "Mike"

I dabble in Rails for fun - it inspires me to do what I do for SubSonic. The one MAJOR PITA however is running it on a Windows 2003 Server box (I have a nice, big, PHAT hosted box with MaximumASP. I really don't want another box running LINUX). While there are some groovy projects out there that install scripts/CGI/rewrites for you, they all seem to be toothpicks and rubber bands that most people agree is just not a good idea for more than a hobby site because it's just plain slow.

I should also add that you can implement a "masking" approach using ISAPIRewrite as well. Basically you setup a rewrite rule for a web site in IIS that hands the request off to a server (like Mongrel) running on a different port. There is a great writeup on how to do this - but try as I might I just couldn't get it to work. I've read mixed reviews on how to get this to scale properly.

Slow? What!
Rails works using CGI - basically an executable that gets run each time a request comes into a web site. Most of the frameworks out there do NOT support multi-threading, so each time a request comes in that requires anything dynamic, CGI is "instanced" and executed. If you have a lot of requests at once, this isn't really a good thing. Now some servers are built to mitigate this (Apache, Lighttpd, etc); IIS is not.

IIS doesn't like to play this way. I can't do the discussion justice, so if you'd like to know more - read Jeff Cohen's writeup here, in this great forum post (it's the 3rd one in).

My New Favorite Person: Mike Volodarsky
If you scroll to the bottom of that forum you'll find that my other favorite person, Mike Gunderloy (his book Coder To Developer changed my life) let the "cat out of the bag" that FINALLY, the IIS team has created a technical preview (aka bleeding-edge bit of software) that will *gasp* run Rails on IIS, flexxing the IIS core architecture. Essentially what it sounds like they've done is to create a "CGI pool" if you will (sort of like an ADO connection pool) that will serve up concurrent requests. Neat idea!

I don't know all the details (I can make them up I spose), but what I can glean from their post is that this implementation of the popular FastCGI engine is much, MUCH faster than most other approaches.

I followed these instructions for setting up Rails on IIS and Windows 2003 Server and I have only a few additions to make that allowed my VM Server here to work:

  • Use the cgi.rb script they provide you. You'll mess up the edit no matter what you do
  • Make sure you restart IIS after you do all the CGI mapping
  • Give NETWORK SERVICE read permission to the Ruby install folder (should be C:\Ruby)
  • Give NETWORK SERVICE read/write permission to your log and tmp directories in your Rails app directory
  • Give NETWORK SERVICE read/write/execute permission to the "fcgiext.dll" once installed
  • Triple check your editing of the fcgiext.ini file. I messed this up 2 times and it resulted in an error

Wrap Up
This is really, REALLY new stuff and the IIS guys are hoping that you give them your feedback either through the forums or by commenting on the blog entry. Probably not safe to put this on a production box :) either but I would imagine that in the next 6 months we'll see a great addition to IIS 6 and 7 for all the CGI-enabled platforms out there.

I, for one, am tickled pink...

Phil Scott avatar
Phil Scott says:
Wednesday, March 28, 2007
Hey Rob, I'm one of the devs here at MaximumASP. Just wanted to drop you a line thanking you for the write up on how to get Rails up and running on server 2003 with the FastCGI. I've been playing around with Ruby on Rails at home for my "fun" projects and I haven't had the guts to install it on my personal server. I might just have to give this a go.

Thanks!

Scott avatar
Scott says:
Wednesday, March 28, 2007
Anytime someone complains about how Microsoft doesn't listen to their customers and we just have to take whatever they shove down our throats, I send them to Scott Guthries blog.

There are lots of teams at MS (cough Office, Windows) that DON'T "get it" (tm), but the BCL, ASP.NET, and IIS teams really do. The FastCGI support is just one example.

Mike Volodarsky avatar
Mike Volodarsky says:
Tuesday, May 22, 2007
Rob,

Thank you for the honor :) I am really happy to see that you are playing with the Ruby support - I would love to hear your feedback around the setup steps, and how things are working out for you in general.

Have you been able to get any serious RoR apps going with it?

Thanks,

Mike


Search Me
Index Of MVC Screencasts

You can watch all of the MVC Screencasts up at ASP.NET, and even leave comments if you like.

Subscribe

Popular Posts
 
My Tweets
  • Isn't the Rails/Asshole thing dead? http://tinyurl.com/57dmvx
  • Pushups last night: 17, 13, 9, 7, 3
  • @kevindente my wife (and me) consider the Roomba to be on par with Tivo in terms of generation-defining technology
  • @kevindente I'll hold you and we can cry together. Maybe you can ... even ... blog about it.
  • Writing tests for InventoryService - talk about a slipper-slope process! Is there such a thing as Cart Concurrency? I dunno! Maybe?
  About Me



Hi! My name is Rob Conery and I work at Microsoft on the ASP.NET team. I am the Creator of SubSonic and was the Chief Architect of the Commerce Starter Kit (a free, Open Source eCommerce platform for .NET)

I live in Kauai, HI with my family, and when my clients aren't looking, I sometimes write things on my blog (giving away secrets of incalculable value).