Thin Web Server Benchmarks
In a previous article, we looked at the performance and memory usage of a Ruby on Rails application running on Passenger Phusion (mod_rails). In this post, we’ll compare the same app running on the Thin Web server behind an Nginx cluster.
Thin Basics
Thin uses the Mongrel parser and Event Machine I/O library. In addition, it uses the Rack interface, allowing you to run other frameworks besides Ruby on Rails.
In a proxying scenario, where Nginx is the “front-end” for the Thin application server, you can leverage Unix domain sockets, which can boost performance and memory usage. Not all HTTP load balancers support it though.
How We Tested
To recap our testing configuration, we’re running a 512MB VPS slice (courtesy of Slicehost.com), and using Apache Bench to load test the login page of our Ruby on Rails blogging platform. This page is not cached but there isn’t a database call either, so our performance numbers don’t include any backend interaction. For other details, refer to the “Benchmark Overview” in our previous post.
Our first test used 4 Unix domain sockets, which are configured as follows, in nginx.conf:
upstream webficient {
server unix:/tmp/thin.0.sock;
server unix:/tmp/thin.1.sock;
server unix:/tmp/thin.2.sock;
server unix:/tmp/thin.3.sock;
}Then, Thin was started up using
thin start -s4 --socket /tmp/thin.sock -e production
Results
Memory usage under load using Thin/Nginx appeared better than mod_rails (with Ruby Enterprise Edition).
total used free shared buffers cached Mem: 524460 458272 66188 0 7060 82792
Requests per second, on the other hand, were a bit slower than mod_rails (246 RPS vs. 292 RPS with mod_rails) but significantly faster than standard Mongrel.
Dynamic Content Load Test – Thin/Nginx
Concurrency Level: 100 Time taken for tests: 40.599507 seconds Complete requests: 10000 Failed requests: 0 Write errors: 0 Total transferred: 30210000 bytes HTML transferred: 25690000 bytes Requests per second: 246.31 [#/sec] (mean) Time per request: 405.995 [ms] (mean) Time per request: 4.060 [ms] (mean, across all concurrent requests) Transfer rate: 726.63 [Kbytes/sec] received
Seeing that we had a surplus of available memory during load testing, we tweaked the number of Unix domain sockets to evaluate the effect on overall performance. However, going from 4 to 5 sockets did not improve performance significantly. Dropping down to 3 sockets decreased performance. Therefore, our recommendation for a 512MB VPS slice is 4 sockets. In another test, we doubled Nginx’s number of worker_processes from 3 to 6, however, this did not significantly improve Thin’s numbers either.
Conclusion
While slightly slower than mod_rails, Thin significantly outperforms a vanilla Mongrel Cluster/Nginx configuration. Thus, Thin is a viable solution to those who prefer Nginx to Apache. Recall that previous benchmarks show Nginx is the clear leader in serving up static content. So if your site uses caching extensively, you may want to consider this setup. Otherwise, Phusion Passenger will give you the best bang for the buck.
Another consideration is stability. Thin has been out for quite some time and has had 7 or so releases. Mod_rails is relatively new and not without issues, as seen in its Google group and blog posts. We’ll expect things to improve quickly in this area.
About this entry
Posted: Monday, June 30th, 2008 at 9:36 pm
- Author:
- Phil Misiowiec
- Category:
- Architecture
- Tags:
- benchmarks, deployment, nginx, performance, ruby on rails, web server
- License:
- Creative Commons

2 Comments
Jump to comment form | comments rss | trackback uri