Archive for November 2008

Modular routing in rails and merb (acts_as_routing)

Here’s a proof of concept plugin that will monkeypatch Rails or Merb routing to allow you to define “acts as blocks” anywhere throughout your application (i.e. a plugin) and then use them in your routes file.
Imagine the plugin acts_as_commentable defines the following in its init.rb:

ActionController::Routing.routes_for_acts_as(:commentable) do |map|
map.resources :comments
map.best_comment ‘/best-comment’, :controller => [...]

JRuby and why it might be nice to be back on the JVM – Part 2

In the previous post, I did some JRuby testing and noticed perf improvements over time.
Mark Imbriaco, of 37Signals, asked how it compared to MRI. I was curious too.
I can’t promise a “clean” comparison, your mileage may vary, but… MRI was:

Completed in 552ms (View: 104, DB: 14) | 200 OK [http://someurl.com/people/3]
Completed in 345ms (View: 60, DB: [...]

JRuby and why it might be nice to be back on the JVM

We ported our Rails application to JRuby in order to do some GC comparisons yesterday. Not a ton of changes required. Mostly replacing gems with native dependencies. YAML is a bit more strict than its MRI counterpart…. but all told, thats pretty amazing! Nice job JRuby crew!
That said…. one interesting, entirely un-scientific, test [...]

Are your mongrels growing by 20MB/request on Rails 2.2? Blame AssetTag!

After porting our production application to Rails 2.2, we noticed a major memory leak.
Beforehand, monit would restart instances a handful of times a day. After Rails 2.2, monit restarted instances THOUSANDS of times a day.
This is a graph of one of our haproxy instances a couple days ago.

We looked at everything, including time spent [...]

How to save 100m of RAM per mongrel (Part 2)

UPDATE I’ve added a patch to Rails Edge for this fix, which is much different than the patch below. See here
In a previous article, I called out the massive memory usage of the default rails resource behavior, and it seems others have as well. In an attempt to decrease the number of routes, [...]

How to save 100m of RAM per mongrel

UPDATE: See Part 2 of this for a better solution
Note: This monkey-patch only works on Rails 2.2
We recently noticed our mongrels, upon startup, were 244M. Eek.

PID USER PR NI VIRT RES SHR S %CPU %MEM [...]