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_analyzerandgem install rails_analyzer_tools;
try runningpl_analyze log/development.logand 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.logand 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..
[tags]Rails, Ruby, performance, profiling, benchmark[/tags]
Tags: benchmark, performance, profiling, Rails, Ruby
http://blog.cbcg.net/articles/2007/04/22/python-up-ruby-down-if-that-runtime-dont-work-then-its-bound-to-drizzown
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…
from the article you pointed above:
I was mad about that. Thanks for the post and the reference about Rails Analyzer tools!!!
[...] write code like here. Filed in [...]