Latest News >> 2008-11-13

Well, DHH seems to be caught in a lie in his latest blog post on Rails myths so I feel I should correct it. An outright lie that Mongrel caused his 400 restarts/day problem. However, David must have forgotten that I have a full log of the chat where he admitted it, so let’s get into some nice clean truth for a change.

2008-11-11

I’m quickly coming to the end of my first semester in music school and am considering taking a consulting gig for the two month break we have. Not really sure what’s available these days, as I actually haven’t touched a computer for the entire semester.

2008-10-30

In this world there are these weird little dickheads who think that they have some kind of magical powers manipulating others to do their bidding. They spend their days making people around them dance like marionettes in a sick little play that only they find funny. The sad truth about manipulators is their machinations are only powerful and effective in their own mind.

2008-10-28

UPDATE: Read my follow-up post to this where I explain Matt is alright.

Ruby On Rails Using SCGI

The SCGI Rails Runner (SRR) is a very small Ruby script for running Ruby On Rails for high-speed deployment of your applications in production. SRR is intended as a replacement for the ancient FastCGI code base and bring some big advantages to Rails deployment for production operations.

What’s SCGI

The Simple Common Gateway Interface is a project to replace CGI and FastCGI with a simpler protocol to both implement and manage. It was written by Neil Schemenauer and adopted by many Python developers as a hosting option. The protocol is so simple that I was able to implement a quick hack version in about an hour the first time I did it.

Getting The Goods

Here’s the quick links to the good stuff right away for those people who know exactly what they want:

Latest release is 0.4.3 released on 23 October 2005.

Advantages

The primary advantages of SCGI over FastCGI are:

  • Simultaneous support for Apache1, Apache2, and lighttpd on OSX, Linux, FreeBSD and Win32.
  • Same performance as FastCGI and better performance than other methods.
  • Is a single cross-platform Ruby script that even runs on win32 (with some restrictions).
  • Works with SCGI modules for Apache, Apache2, and Lighttpd webservers.
  • Simple to install, run, and configure.
  • Supports simplified clustering on most POSIX systems for that extra boost in concurrency.
  • Accessible via DRb (distributed Ruby) so you can create remote management systems.
  • Gives out great status information to help manage your Rails application’s resources.
  • Makes it easy to manage your production deployment, and you can even run your application in development mode exactly the same way as with script/server for extra testing efficiency.
  • It can throttle connections to reduce the load on the server.
  • You can set a maximum concurrent connections limit, which causes any connections over the limit to get redirected to a /busy.html file. This can help keep your site alive under heavy load.
  • Simple to configure with your web server. Even if you use clustering you’ll be able to manage your webserver and Rails application independently.
  • Reasonable defaults for almost everything based on user feedback.
  • Completely free code licensed under Rails’s own license.

Downloads

You can grab the latest version from my downloads directory in various formats. Version numbers are always increasing so hopefully you can figure out which one is the latest. For example, 0.4.3 is more recent than 0.4.2.

Dependencies

You need to have cmdparse 2.0.0 or greater and highline 1.0.1 or greater. If you install by gem then this should be done for you.

Install

The quick guide to installing SRR is to simply download the gem and install it directly:

wget http://www.zedshaw.com/downloads/scgi_rails/scgi_rails-0.4.3.gem gem install scgi_rails-0.4.3.gem

That should do it for just about everyone. If you’re allergic to RubyGems or have the need to install directly, then you can do the following:

wget http://www.zedshaw.com/downloads/scgi_rails/scgi_rails-0.4.3.tar.bz2 tar -xjf scgi_rails-0.4.3.tar.bz2 cd scgi_rails-0.4.3 sudo ruby setup.rb

If you don’t know what any of those commands do then just install the gem or learn to use Unix.

Documentation

There’s a fair bit of documentation in the works, with more to come. Feel free to suggest other information if you can think of any.

  • README and RDoc
  • FAQ—Frequently Asked Questions with solutions.
  • HOWTO—Helps you get started and do some advanced stuff with SRR.
  • Lighttpd Configuration—Configuration for lighttpd 1.4.4 (works with others, but YMMV).
  • Apache2 Configuration—Configuration for Apache2 (not win32 though).
  • Apache1 or Apache2—Win32 install with pre-compiled mod_scgi.so for both servers.
  • Performance Analysis—Compares SRR with other methods to validate performance requirements. Lost of statistics here so you probably will not be interested.

Suggesting Improvements

The best way to suggest improvements is to contact me via e-mail. Since I really detest spam and crazy idiots I seem to find on the Internet, I’m leaving it to you to figure out my e-mail address. I’ll give you a hint though: My name is Zed Shaw. I have a website named zedshaw.com.

I also like receiving bug reports that have lots of information in them. I’ll usually help anyone who asks, but you can probably get faster response if you hop onto irc.freenode.org and go into the #ruby-lang channel looking for zedas (that’s me).