Rails vs Merb & ActiveRecord/Datamapper

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.

6 Comments, Comment or Ping

  1. Why don’t you just write mongrel/rack handler using mysql gem directly ?

  2. admin

    :) If I get bored one of these days, it might be an interesting experiment…

  3. A naked thin rack handler performs around 3x better than Merb-core. It’s totally worth it :-)

  4. Rowan,

    Wow. These results actually surprise me a bit. :-) I’ve actually been telling people DM 0.2.5 onwards is nothing to brag about performance wise. :-D

    That will change in the next few weeks of course. A friend and I have actually been working on DataObjects tonight, and do_mysql is preliminarily about 3X faster than it was before (and 3X faster than the ruby-mysql gem ActiveRecord uses as well). So the 0.9.0 release should take no prisoners as far as performance goes. :-D

    Anyways, thanks for the press. Now isn’t necessarily the best time to get into DM with all the changes coming up with 0.9.0, but give us a few more weeks and we’ll be there and be able to turn our focus back to bug fixes.

  5. admin

    Wow Sam that sounds awesome - yep this post is just for investigative purposes, not looking at it for production -Yet !! Watching this one with eagle eyes as it looks very promising …

  6. Varun Malhotra

    which version of datamapper did you use..The one I am trying gives me an error.

    Also, what procedure did you use to measure the thruput?

    thanks

Reply to “Rails vs Merb & ActiveRecord/Datamapper”

About

Rowan is a Product Development Manager, specialising in architecting, developing and putting web applications into production - in particular Ruby on Rails based apps. He lives in Toronto, Canada but speaks in a funny accent as he's originally from New Zealand. He's been working in the software and web business for over a decade. This blog covers Web Application development and deployment in the real world, dealing with topics from business fundamentals to Ruby on Rails, Merb, PHP, Flex, MySQL, Apache and more.

Read more ...

 

 

View Rowan Hick's profile on LinkedIn

 

Subscribe to my RSS feed