Politics, Programming and Possibilities
2 Aug
My friend Ezra has been building a new MVC framework for Ruby that I’ve suddenly become quite fond of: it’s called merb, and it’s fast. I like fast—especially now that I’ve built several Rails apps and felt the pressure mount when the app tops at 20 requests per second.
Here’s what Ezra wrote to me when I asked about performance:
Merb is a lot faster then Rails as far as routing and dispatching, filters, action calling. The whole framework is built for speed. I want the time spent during a request to spend very little time in framework code overhead and more time in your own application code. Merb does this very well. A hello world action is about 700req/sec and if you use the event driven mongrel its 1200req/sec for a single merb backend.
So merb can go very fast and has way less overhead then rails does. In rails there is a lot more to do in the framework code before it passes control and your own code gets a chance to run.
And regarding reliability in a production environment:
Merb can handle a lot more concurrent requests on one process than rails can. It can also be run in a fully multi threaded way with no mutex lock if you don’t use activerecord and instead use a thread safe ORM like Sequel. Merb processes in general use about half the ram or less of rails processes and tend to not leak like rails [sometimes] does. One guy is running a file upload type site http://dropboks.com on 4 merbs and he does 500k uploads a day and a ton of downloads. Everything is stored on s3 but proxies and streams thru merb going up and going down.
Just for the record, Ezra is working on this project in his own free time, so send him the positive remarks and please be kind if your performance or reliability isn’t exactly as quoted. As an open source project, you’re free to help out if you find any deficiencies.
As a note to myself and others, here are the gems I’ve installed for merb:
I’ve needed the following for running the tests / specs:
And from what I understand, I will need to use a thread-safe data source such as Sequel to let merb do its fantastic multithreading work:
If you’re into more control over your queries than ActiveRecord gives you, I’d recommend checking Sequel out. It’s code is full of some very neat Ruby as well as a surprising dash of semantic beauty.
3 Responses for "Magnificent Merb (and Sequel?)"
I like Merb too, I think that Ezra is one of the pinacles on Ruby performance. I am all for a good high-performance, concurrent web framework, but instead of building new alternatives from scratch I always wonder if it is not possible to tweak Rails itself, optimize it. Building something new always means another learning curve, redundant code and libraries. Rails already have the market share, the community attention, lots of documentation and support. Even though I like the ideas behind Merb I think it could do much better to add these to Rails. For example, ActiveRecord was not thread-safe, but after some tweaking from the Core Team and the community they were able to make it thread-safe. Well, just my 2 cents.
Originally I was working on improving rails itself instead of making a new framework. The problem is that Rails is just to big at this point and has too much backwards compatibility baggage to make radical changes to the code. It has matured to the point where radical changes are very hard to accomplish without pissing people off by breaking some feature they were using.
We all love rails, myself included. But there are some things I don’t agree with in the rails code base. People say constraints are liberating but I think constraints are also constraining
Merb is going to be a lightweight hackers framework. Small core that is easy to extend, everything else is a plugin. I don’t need the kitchen sink.
Now if the rails core team wanted to release the current edge rails as rails 1.5 or something and would allow for some serious refactoring and BC breakage for rails 2.0 then I would gladly apply all of merb to rails 2.0 and kill the merb project.
But I serioulsy doubt that is going to happen. Rails code base has gotten huge and complicated with tons of uneeded cleverness just for cleverness sake. I’d love to see Rails2.0 really thin down the core framework and rewrite all of ActionPack/ActionView.
Ever wanted rSpec to work with merb? Took a while, but now you can!
http://blog.xnot.org/2007/08/09/rspec-on-merb/
Let me know how it works for you
Leave a reply