April 11, 2006 @ 12:41 AM
setting up litespeed with mongrel
I’ve been running both this weblog and Rails Weenie on mongrel and litespeed for a couple weeks now, so I wanted to write a couple notes on how everything is set up.
Setting up Litespeed to host Rails applications is dead simple, especially if you go by Bob’s Launching Rails at the Speed of Lite article. The only part that’s different is setting up the external application for mongrel instead of FCGI. Instead of an external FCGI application, this weblog uses an external web server application on a unique port. Rails Weenie gets a lot more traffic, so I decided to set up three external applications: Two web servers and one Load Balancer. Here’s what my external applications tab looks like for rails weenie:
| External Applications | ||
|---|---|---|
| Type | Name | Address |
| Web Server | rails-weenie-xxx1 | 127.0.0.1:xxx1 |
| Web Server | rails-weenie-xxx2 | 127.0.0.1:xxx2 |
| Load Balancer | rails-weenie-load-balancer | N/A |
After your external applications are set up, all you need is a Litespeed context mapping the / url to either the load balancer or a single web server. Now, you are free to start/stop the mongrel processes as you wish. Here’s a sample mongrel command:
mongrel_rails start -d -e production -p xxx1 -P log/mongrel-1.pid
mongrel_rails start -d -e production -p xxx2 -P log/mongrel-2.pid
So how well does this all perform?
I currently get between 300-400 requests/second, according to some benchmarks that Jason ran for me. He was also nice enough to compile the ruby-sendfile plugin for me, bringing the total requests/second up to around 450-500.
That is pretty fast, until you consider that most of the site is page cached. My old mac mini easily gets 1000 requests/second from page cached rails apps. So, what’s the deal? The fact is, lighttpd completely bypasses Rails if it finds an existing file. No matter what Zed does on the ruby side, it could never compete with a c++ web server. However, since mongrel functions as a full web server, it feels compelled to serve static as well as dynamic requests.
What are our options?
- Zed shows how to use lighttpd’s CML feature to serve static files with lighttpd and dynamic files with mongrel in the Lighttpd tutorial.
- Zed has mentioned supporting the X-Sendfile header. Mongrel could simply return this, telling the frontend web server to serve the file. I’m not sure if lighttpd or litespeed support this currently.
- The ruby-sendfile gem helps if you’re OS supports it, as I found out above.
- Zed also brought up the TUX Web Server, a super-fast kernel-based web server for serving static files.
Comments are closed.
