Performance Comparison of Ruby Frameworks: Sinatra, Padrino, Goliath, and Ruby on Rails
The main goal of this article was to find the best framework for a very basic but highly loaded Ruby application. This is the updated version of the comparison that was first posted in Jun 2013. Now we ran all the tests again, using the latest versions of Sinatra, Padrino, Goliath, and RoR. Unfortunately, the Espresso framework that we had tested last time disappeared from all the repositories, so it is no longer included.
We used the following test infrastructure and settings: ApacheBench 2.4.3 ab -n 1000 -c 100 localhost, a 2.3 GHz Intel Core i5 Sandy Bridge CPU, 4 GB of 1333 MHz DDR3 RAM, a 120 GB Intel 330 SSD, OS X Mavericks 10.9.1, Ruby 2.0.0p247, and MySQL 5.6.14 in a development environment.
All the tables below contain data on the time it takes to process 1,000 requests.
Let’s start with Sinatra. It turned out that Unicorn works faster with MySQL and Views than with Views only, but since the difference is very small (0.005 s), this might be due to an error.
To eliminate any inaccuracies, we re-checked all the controversial results many times and got pretty stable values. So, you should be extremely careful when building high-load applications, because any small changes may slow them down. We recommend that you always run benchmark tests to the Web server you want to use in production.
Since Thin demonstrated the best results while keeping the application very simple, we decided to use it for the rest of the tests.
Although the Padrino framework is built on Sinatra with a lot of helpful features, like in Rails, its performance is still close to that of a clean Sinatra application. This is very good news for us.
The results for Goliath look a bit strange, because we expected this framework to be the fastest, thanks to its own HTTP server. If you test it and get different results, please do not hesitate to mention that in the comments and/or propose your version of the benchmark test.
We also decided to test Rails 4.0.2. For these tests, we enabled caching classes in development.rb and disabled sessions and protection from forgery. We also used the Sequel database toolkit instead of ActiveRecord to make the results more trustworthy. As you can see, they turned out to be close to Goliath’s, but slightly better.
You can take a look at the applications I created for these tests to make sure they were really similar. Hope this article helps you to choose the right Ruby framework. Feel free to leave your comments below.
p.s. Special thanks to Alexander Kuntsevich, our Ruby developer, for his assistance.
Download a more detailed version of the comparison (with 10 diagrams) here:
Performance Comparison of Ruby Frameworks: Goliath, Ruby on Rails, Sinatra, Padrino, and Espresso
About the author
Eugene Melnikov is a senior developer at Altoros with 5+ years of experience in Ruby, Rails, AngularJS, and Node.js. His professional interests also include сloud computing and automated testing. You can find him on GitHub.18 Comments