Ruby web server performance
I’m currently helping a colleague to build a rather large community website using Ruby on Rails. As most Rails developers are well aware, Ruby isn’t exactly the quickest language you can use to build web applications. To get a rough idea of how much users our current code would handle, I decided to run some performance tests.
First, here’s a picture of the page that was used.
The page has a tagcloud, site statistics and a conditional menu in the upper right corner.
For the benchmark I’m using the following tools
ApacheBench 2.0.40. To fire off a large amount of requests into the webserver.
Mongrel 1.1.3. One of the Ruby web servers
Thin 0.6.4. An alternative to Mongrel.
nginx 0.5.26. A lightweight HTTP server, which will act as a proxy/balancer in front of the Ruby application servers
For the benchmarks I settled on the following scenario’s.
Single instance of Mongrel in development mode
Single instance of Mongrel in production mode
Cluster of 4 Mongrel instances behind nginx
Cluster of 4 Thin instances behind nginx
In a real production environment, you’d never see the single Mongrel instance, and certainly not in development mode. The graph will show you why.
The red bar is for 50 concurrent requests, with a total of 10000. The red blue is for 10 concurrent requests, with a total of 10000.
The raw numbers:
| 10 concurrent | 50 concurrent | |
| Mongrel (development) | 4.88 req/s | 4.59 req/s |
| Mongrel (production) | 77.15 req/s | 67.18 req/s |
| Mongrel cluster + nginx | 130.97 req/s | 122.04 req/s |
| Thin + nginx | 156.21 req/s | 160.89 req/s |
I’m pleased with the results, we still have a lot of stuff we could cache and database queries that could be optimized, so there’s room for improvement. The server that will eventually host the application runs an Apache proxy going to mongrel_cluster. I’m probably going to run some benchmarks later, to see how Apache proxy holds up against nginx.
Whenever you need some information or need to make a small note, you press that keyboard key and the widget layer is displayed. Pressing the same key again and the widgets disappear.

I’ve 


