Ship It! LIVEShip It! LIVE
home about services writing contact

We develop, test, and create fine software products, and design creative solutions to your problems.
The development of software is an intrinsically creative process. We are dedicated to improving our mastery of the art.
Links · RSS Feed
Popular Pages

..."Ship It!" is in the style of the other Pragmatic books and is an easy and focused read. I finished it in two days and have already gained a wealth of insight that I can apply immediately. Hig...
-Anil John
They have gathered together the ‘best bits’ of various styles and methodologies they have been directly involved with, and combined them into a practical approach with the focus on delivering a pro...
-Mitch Wheat
It's rare to have this much fun reading a book about software. The ideas are smart, relevant, and fundamental. I can be a better programmer today because of the things I read today.
-Joe Fair

Nginx: My New Web Server (Jun 10)
I recently heard about Nginx. It's a web server with a great track record in Russia that's starting to spread out to the rest of the world. According to a recent podcast I heard, Zed seems to be using it with his production Rails apps, which is always a good sign. At RailsConf I got to eat with Adam Keys and his enthusiasm for it's speed, ease of configuration, and stability caught my attention.

The greatest attraction for me is the ease of configuration. I've wrestled with Apache conf files on and off though the years, but I've never felt like I really "got it". Apache can do nearly anything, but you've got to really invest the time to become an Apache specialist to do anything useful with it. And I never really felt the motivation to become an Apache specialist.

When I set up this web site, I tried to get my Mongrel cluster up and running with Apache but couldn't get it working. So I gave up and dropped back to Pound and Mongrel. Pound load balanced and Mongrel served everything, including the html, Javascripts, CSS, and graphics. A complete reload of the main page took about 30 seconds. Nearly all the time was spent loading graphics, two at a time. And once the browser had the graphics cached, it ran great.

But today I switched to Nginx and a clean reload is taking me 8 seconds. Granted, Mongrel wasn't designed to serve your static content, but wow... that's an improvement!

Here are some Nginx links to get you started.

And here's my configuration file:

worker_processes  2;
events {
    worker_connections  1024;
}
http {
    include       conf/mime.types;
    default_type  application/octet-stream;

    upstream mongrel {
        server 127.0.0.1:7000;
        server 127.0.0.1:7001;
        server 127.0.0.1:7002;    
        server 127.0.0.1:7003;
    }
    log_format  main  '$remote_addr - $remote_user [$time_local] $request '
                      '"$status" $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    sendfile        on;
    server {
        listen       80;
        root /usr/local/nginx/html;
        access_log  /usr/local/nginx/logs/access.log  main;
        rewrite_log on;

                location ~ ^/$ {
                  if (-f /index.html){
                    rewrite (.*) /index.html last;
                  }
                   proxy_pass  http://mongrel;
                }

                location / {
                  if (!-f $request_filename.html) {
                    proxy_pass  http://mongrel;
                  }
                                        }

                location ~ .html {
                   root /usr/local/nginx/html;
                }

                  location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar
|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$ {
                  root /usr/local/nginx/html;
                }
         }
}

Update: Apparently this call request.host_with_port gets confused when Nginex proxies for Mongrel. If you're reading this via the RSS feed, then you probably noticed that all my URLs were wrong for a few hours. It's fixed now. I should wrap that with a test!

Category: Rails

New England Software Symposium (2008-09-12)
Back in Boston! I'll be speaking on Saturday and Sunday.
Pacific Northwest Software Symposium (2008-09-19)
Back on the west coast. I'll speak (and keynote) on Friday and Saturday in Redmond.
Agile Development Practices (2008-11-10)
Any conference in Orlando is good, but this one is great!
Agile One: Boston (2008-11-18)
The first Agile Experience was a huge success. Tell your manager about this one.


© 2007 Agile Artisans.