Rails 11 Feb 2007 07:37 pm
Nginx at 10,000 Feet
Lately, five letters have begun to rattle around the Ruby on Rails universe with increasing frequency: nginx (allegedly pronounced “engine x”). This new toy is a reverse proxy HTTP server that can serve as a high-performance, lightweight replacement for Apache. In particular, it works well as a load-balancing front end for a Mongrel cluster running a Ruby on Rails application.
According to one elated nginx user:
The only solution I know of that’s extremely high performance that offers all of the features that you want is Nginx… I currently have Nginx doing reverse proxy of over tens of millions of HTTP requests per day (thats a few hundred per second) on a single server. At peak load it uses about 15MB RAM and 10% CPU on my particular configuration (FreeBSD 6).
Under the same kind of load, Apache falls over (after using 1000 or so processes and god knows how much RAM), Pound falls over (too many threads, and using 400MB+ of RAM for all the thread stacks), and Lighty leaks more than 20MB per hour (and uses more CPU, but not significantly more).
It does seem like a lean, powerful solution for sites that control their entire technology stack; of course, it doesn’t help those of us on shared hosting providers like Dreamhost who must wait for the admins to carefully and excruciatingly evaluate each new service they roll out.
A quick Googlry turns up quite a few articles on nginx:
“Nginx, my new favorite front end for mongrel cluster” by Ezra Zygmuntowicz
“High-Performance Ruby On Rails Setups Test: mongrel vs lighttpd vs nginx” and many other nginx articles by Alexey N. Kovyrin
“(Rails Deployment – Apache – Lighttpd) + Nginx & Mongrel Cluster” by LabRat
“Time For A Grown-Up Server: Rails, Mongrel, Apache, Capistrano and You” by Coda Hale
“nginx: the front end solution for rails deployment?” by Dominic Damian
If you’re able, I’d highly recommend checking it out. On the other hand, if you’re one of the poor, lonely stack-impaired minions like myself, maybe you can wring a few drops of vicariousness from the gushy victory stories above.
