If you’re getting to this page from searching “Rails vs Merb” I suggest you read/view this presentation I did http://work.rowanhick.com/2008/06/11/toronto-rails-night-merb-presentation/
Following on from my presentation last week, I had someone mention I should look at Merb+Datamapper if I’m looking for something awesomely fast. So I decided to put it to the test. This is a *completely* contrived - I’ve done enough benchmarking to know this, so take the following figures with an (extremely) large grain of salt, I’m just posting this for interest. The view being rendered is a real world view that I’m using for a rewrite of a PHP/MySQL app, listing out orders by order status, along with their customer and originating country.
I’ve got a database of Orders(770), OrderStatuses(17), Customers(300), Countries(244). I have a find by sql statement I’m using to pull upto 100 orders like so:
"SELECT orders.id, orders.created_at, customers.name as customer_name, countries.name as country_name, order_statuses.name as status_name FROM orders LEFT OUTER JOIN `customers` ON `customers`.id = `orders`.customer_id LEFT OUTER JOIN `countries` ON `countries`.id = `customers`.country_id LEFT OUTER JOIN `order_statuses` ON `order_statuses`.id = `orders`.order_status_id WHERE (order_status_id < 100) ORDER BY order_statuses.sort_order ASC,order_statuses.id ASC, orders.id DESC LIMIT 100"
The same statement is used in all 3 applications, along with the same generated html. All 3 apps were run daemonized in production mode using mongrel. The resulting page is comprised of a layout + js + css files, that each app is serving identically.
Using Rails: 42.16 req/s (baseline)
Using Merb + ActiveRecord: 57.80 req/s (1.37x)
Using Merb + Datamapper: 72.98 req/s (1.73x)
So lets up the order count to 11550. As the volumes of data goes up (and therefore database tuning becomes more important) these are the following figures…
Using Rails: 22.82 req/s (baseline)
Using Merb + ActiveRecord: 29.85 req/s (1.30x)
Using Merb + Datamapper: 33.91 req/s (1.48x)
Merb+Datamapper still outshines the competition, but the difference in performance isn’t quite as significant, however once the DB is tuned, I bet life gets more interesting….
Again before I get lambasted, take the figures with a grain of salt, the times do vary quite significantly as there are variables aplenty, just look at the general trends.