Ruby on Rails - 1-2-3 to performance analysis

My cool colleagues from Trex Global gave me an unusual assignment this week: profile the current implementation of our first two apps, DeferEm and DepreciateEm.

Among the requests, the usual ones:

Request response duration
Execution profile of flow (path taken, time in methods)
SQL Queries made
Analyze and Identify performance bottlenecks - in-memory, sql query exec

After the initial despair of meeting the first time such a task, I remembered: after all, the development.log file records every controller method, action, view, SQL request as well as their execution times. So my first thought was to start digging into the log/development.log file and start grepping the heck out of it.

Wait. Don’t rush into it. There are other ways to do this.

So, after A LOT of googling, I found out about the cool and great Rails-Analyzer Rails performance analysis suite.

  • Step 1: gem install production_log_analyzer and gem install rails_analyzer_tools;
    try running pl_analyze log/development.log and see some weird errors related to logging.
  • Step 2: check out Geoffrey’s article over here ; download his logger replacement and add the two lines
    require 'hodel_3000_compliant_logger'
    config.logger = Hodel3000CompliantLogger.new(config.log_path)

    in the config/environment.rb file ; so now you get something like


    Rails::Initializer.run do |config|
    # Settings in config/environments/* take precedence those specified here
    require 'hodel_3000_compliant_logger'
    config.logger = Hodel3000CompliantLogger.new(config.log_path)

  • Step 3: Run again the pl_analyze command:
    pl_analyze log/development.log and enjoy the coolness of a beautiful report

Now I’m a happy man. But I still have work to do: ho do I find, for instance, the worst performing SQL requests?

We’ll see about that soon..

Articole inrudite

4 comentarii

  1. Publicat April 27, 2007 la 11:35 am | Permalink
  2. Publicat April 27, 2007 la 11:48 am | Permalink

    thanks for the link, but let’s not start a flame over python vs ruby: i agree, python is faster than ruby; but one must also acknowledge that rails is years ahead of django productivity-wise; simply put, the Rails community is HUGE.

    Sure, once you become as famous as twitter you’re bound to have make some major performance tweaks, or else you’re doomed; still, there are some major websites out there running rails, and it seems like there’s nothing some perf tuning and extra servers won’t manage…

  3. Publicat April 27, 2007 la 11:49 am | Permalink

    from the article you pointed above:

    : I think Rails is great for what it is and I’ve had nothing but good experiences with it precisely because it is so “opinionated”. Its a very productive environment and manages to successfully avoid the runtime problems that I’ve personally hit in the past. I hope that the Ruby community can really bang out a worthwhile runtime in the coming year and if they do, I’m back on board. If I get some time, I might even help out where I can.

  4. Publicat May 11, 2007 la 1:29 pm | Permalink

    I was mad about that. Thanks for the post and the reference about Rails Analyzer tools!!!

Un trackback

  1. [...] write code like here. Filed in [...]

Lasa un comentariu

Your email is never shared. Campurile obligatorii sunt marcate cu *

*
*