Ruby 1.9 vs. Ruby 1.8 real-life speed benchmark, no database
I decided that it will be great to make a benchmark of how the blog runs with the two interpreters. Here are the description and the result.
- Machine: Apple MacBook Pro, 2.5 GHz Intel Core 2 Duo, 4GB 667 MHz DDR2, 250 GB HDD, 5400 RPM, Mac OS X 10.5.7
- Ruby 1.8.7 p72, 64 bit
- Ruby 1.9.1 p0, 64 bit
- Sinatra 0.9.2
- rdiscount 1.3.4
- haml 2.0.9
- thin 1.2.2
- mongrel 1.1.5
- nginx 0.7.61 as reverse proxy
The logic behind the test
The page that I tested with was doing the following actions:
- Open around 18 files from the filesystem and read their first 3 lines
- Parse the lines using regex
- Parse some dates from the data read from the files
- Read 5 of the files in-memory
- Render some HAML templates with content got from the read files
There is a git repository with the code. It is my blog.
The test candidates
I tested the following configurations:
- 5 Thin instances running Ruby 1.8 behind nginx reverse proxy
- 5 Mongrel instances running Ruby 1.8 behind nginx reverse proxy
- 5 Thin instances running Ruby 1.9 behind nginx reverse proxy
I use thin because this is the only web server, that compiles against ruby 1.9 on my machine. I even had to compile it myself, because of the 64 bit interpreter that I have (also custom compiled).
The tests were performed with concurrency 10 and 1000 requests. Here is the command line I used:
# ab -c 10 -n 1000 http://127.0.0.1:8080/
|Ruby 1.8 + thin||19.55||511.599|
|Ruby 1.8 + mongrel||18.07||553.511|
|Ruby 1.9 + thin||42.86||233.336|
Here are some graphs of the results
As you see using ruby 1.9 boosts the performance of the application more than 2 times.
Here are links to the extended info generated by ab:
I will be glad to hear your comments about the test and your experience with ruby 1.9. For the real enthusiasts this site provides info about what gems are 1.9 compatible.