#161
May 11, 2009

Three Profiling Tools

Ever want to know what Rails is doing under the hood during a request? In this episode I show three different profiling tools: New Relic RPM, FiveRuns TuneUp, and Rack::Bug.
Download (19.8 MB, 7:02)
alternative download for iPod & Apple TV (10.9 MB, 7:02)

Resources

script/plugin install http://newrelic.rubyforge.org/svn/newrelic_rpm
sudo rake gems:install
script/server
script/plugin install git://github.com/brynary/rack-bug.git
mate config/initializers/middleware.rb
# config/environment.rb
config.gem "fiveruns_tuneup"

# config/initializers/middleware.rb
require "rack/bug"

ActionController::Dispatcher.middleware.use Rack::Bug,
  :ip_masks   => [IPAddr.new("127.0.0.1")],
  :secret_key => "epT5uCIchlsHCeR9dloOeAPG66PtHd9K8l0q9avitiaA/KUrY7DE52hD4yWY+8z1",
  :password   => "secret"

RSS Feed for Episode Comments 29 comments

1. Steven E. Price May 11, 2009 at 00:22

Always look forward to your screen cast every Monday morning! Keep it up!


2. Brian Pokosh May 11, 2009 at 01:31

RPM is available as a gem as well, at least for production mode.


3. RailsCasts Fan May 11, 2009 at 06:08

Yeahhh, monday! I so waited this moment. ;-) An another great and useful screencast, thank you! Ryan for the win! :-)


4. Andrew Cetinick May 11, 2009 at 06:12

Comfirmed. You can use it as a gem in development too.


5. Tim Morgan May 11, 2009 at 08:53

Ryan, I would love to hear which one of these tools you like the best, and which one you use (if any).


6. Ryan Bates May 11, 2009 at 09:24

@Tim, I don't use any of these on a day-to-day basis, but I will boot one up occasionally when I need to figure out what Rails is doing.

Most often this is NewRelic's because it is most convenient if you are already using it for production too. But I am very intrigued by the other two, especially Rack::Bug which offers a boat-load of useful information and is extendable.


7. Eric Berry May 11, 2009 at 09:44

It seems that every time I have tried to integrate Five Runs into my application, I always get buggy results. This time I can view the drop down information, but there is now way for me to delve in deeper into the models and queries. I think the latest may only be useful for Rails 2.3.2 and not older. I'm running 2.2.2.

Great screencast though, Ryan! I wish I could have made it to Railsconf so I could have met you in person.


8. Shreyans May 11, 2009 at 14:14

Good news! Rails resources increasing! We got another site that posts podcast and video tutorials online! Just to let you all know this.. Please visit http://www.buildingwebapps.com/podcasts
We should really support these initiatives. Thanks Ryan and thanks Michael Slater/Christopher Haupt from LearningRails. You guys are doing a great job. Keep it up!


9. Will Clark May 11, 2009 at 17:45

Very cool. Thanks a bunch Ryan!


10. Kieran May 12, 2009 at 00:57

You may want to note that rack bug only works with Rails 2.3 or later. I tried on 2.1 and 2.2 and doesn't work because there is no ActionController::Dispatcher


11. Todd May 12, 2009 at 06:25

The relic plugin isn't available at the momement
script/plugin install http://newrelic.rubyforge.org/svn/newrelic_rpm
.
.
.
+ ./lib/new_relic/config/ruby.rb
Plugin not found: ["http://newrelic.rubyforge.org/svn/newrelic_rpm"]


12. Chris May 12, 2009 at 07:11

What is the best choice in production mode new_relic or 5runs?


13. Denix May 12, 2009 at 07:31

And how can I profile actions which are called with Ajax?


14. Michael May 12, 2009 at 11:42

Hey Ryan, nice cast!

Got a off-topic question. What do you use to syntax-highlight your code snippets in the show notes?

I was looking around and couldn't find a good one.

Thanks!


15. Mourad May 12, 2009 at 12:17

Thank you Ryan for your great efforts ;-)


16. Todd May 12, 2009 at 22:45

new_relic requires that you give them your email address and then they give you a config file. Otherwise you can't use it.

 Tune-up on Ubuntu doesn't work well because it creates files that require root access. I've been unable to find the correct chmod to resolve this problem as it seems to create some files each time at start-up.


17. Jaime Iniesta May 13, 2009 at 07:41

Thanks for your railscast, Ryan! Nice compilation. I use mostly NewRelic for staging and production environments, and MySQL Query Reviewer for development mode:

http://flouri.sh/2008/4/10/mysql-query-reviewer-now-with-ajax-and-profiling

I find this last one really helpful and unobstrusive. You just put it in your app, no config files, and it will show a tiny floating div you can unfold to get more details of the queries, with helpful tips to get a better performance on them. Only works with MySQL, though.


18. music May 13, 2009 at 23:38

Great post!


19. Water meter fittings May 20, 2009 at 20:17

Very cool. Thanks a bunch Ryan.


20. deto May 21, 2009 at 12:31

Very cool stuff, thanks Ryan.


21. Sergei O. Udalov May 24, 2009 at 06:08

and what about security when using newrelic? everybody can see my logs. am i right? :)


22. Irusya Jun 09, 2009 at 21:00

Thanks Ryan. Good job.


23. Alexander Sorokin Jun 28, 2009 at 13:41

Thanks, Ryan. Very interesting episode (as usual). You're saving me a lot of time searching new rails gems/plugins.


24. Алина Кириловна Jul 05, 2009 at 07:02

Спасибо за новость и этот прекрасный сайт! респект и уважуха!


25. preemie baby clothes Oct 19, 2009 at 06:17

Hey Ryan,

Thanks for the post. The blog's great as well. Keep up the hard work.


26. Dom Jan 03, 2010 at 18:04

Getting "Plugin not found" when running "ruby script/plugin install http://newrelic.rubyforge.org/svn/newrelic_rpm", why is that? :S


27. wholesale nike shoes Jan 13, 2010 at 23:01

A very good article, I will always come in.


28. wholesale scarves Jan 13, 2010 at 23:01

Such a good article, caught my sympathy!
-


29. Louis Vuitton handbags Mar 09, 2010 at 19:01

railscasts.com/episodes/161-three-profiling-tools

Add your comment:

(SKIP THIS ONE)

(required)

(not shown)


(use pastie or gist for code)

sponsored by:
if you want to help:
required:
Get Quicktime Player
Give Back to Open Source