#97
Mar 17, 2008

Analyzing the Production Log

In order to improve performance of your Rails application you need to find the bottlenecks. A great starting point is your production log. In this episode you will see how to use RAWK to analyze your log file and determine which controller actions take up the most processing time.
Download (8.5 MB, 5:55)
alternative download for iPod & Apple TV (7.7 MB, 5:55)

RSS Feed for Episode Comments -42 comments

1. QuBiT Mar 17, 2008 at 03:24

Hi,

really nice and handy, waiting for more ;-)


2. philippe Mar 17, 2008 at 07:13

Félicitations pour votre formidable travail, à la fois pertinant et très utile.
thx.


3. drozzy Mar 17, 2008 at 10:51

i really wish you'd do more casts on some more basic things, they were great! ... these things are way over my head ;-(
But maybe it's just me.


4. Morgan Roderick Mar 17, 2008 at 15:14

Looks very interesting, am looking forward to the next episodes.

One thing though, how exactly do you get the log to show this pid's?

I cannot get my 2.0.2 to alter the log messages, and thus cannot group by controller actions.

Perhaps a sample environment.rb and a sample log would clear it up for people as thick as me ;-)


5. chris Mar 18, 2008 at 21:51

I have to say that I have learned so much watching your railscasts, it really been such a great help at my job. The only thing else i could ever ask for is more examples.. will be watching your rss feed ;)


6. Flinn Mar 19, 2008 at 20:49

I've had success using Rawk to analyze several gigs of logs. It's really nice if you have logs spread out over a number of machines. It's easy enough to cat them together and send them to Rawk. Rawk seems to be pretty fast and provides very useful output <b>without</b> the need to modify the logger.

My favorite flag is -w 20 which will give the 20 worst requests. If you have a very high traffic site these 20 worst offenders might be hogging up mongrels or your DB (-d).

Waiting for the follow up to this.


7. Vern Mar 21, 2008 at 08:37

Just started using RoR a couple of weeks ago... by accident. A client moved to a new host and they offer RoR as part of the package for all customers.

I never heard of it before.

I had already started building a PHP job tracking application for the client and when I realized what RoR was... I scrapped the whole thing and started over. YEEEHAAA! This is rocking my world.

Now my brain is exploding. Had to delete all those Love Boat reruns to learn this stuff.

These Railscasts are FANTASTIC! I have one tiny small criticism... that intro scares me. I have to fast forward my DVDs when it plays that THX promo (the audience is NOT listening)... same thing here. I have to fast forward past that Railscast intro or I get anxious.

Other than that these are PERFECT and very very helpful.


8. Carl Mar 21, 2008 at 14:42

Vern,

I know exactly what you mean, I always skip past the beginning, too, though it's because I'm usually at work, and I'm afraid somebody will misunderstand what I'm doing (no one here understands what I actually do anyways) and think I'm just streaming entertainment. Well, I'm sorry, but my entertainment is educational and what lets me do this 'magic' that I do all day.


9. Ryan Bates Mar 24, 2008 at 00:13

@drozzy, the next few episodes will be a bit more advanced, but in the near future I hope to bring in some more basic ones. Thanks for the suggestion!

@Morgan, oops! I completely forgot to address this issue! Rails 2.0 uses a BufferedLogger which I'm not sure allows you to customize the format as easily. Instead you can switch back to the old logger. I *believe* this line will do it in the config file, but I haven't tested it yet.

config.logger = Logger.new(config.log_path)

Thanks for catching that.

@Vern & Carl, sorry about the intro. I'll consider changing the sound effect. Maybe a nice little squeaky toy or something. ;)


10. Carl Mar 24, 2008 at 12:33

@Ryan, you could do it as a psychological experiment. Pavlov would be proud at the way you've got at least a couple of us trained to drool (or jump) at that sound, I'm sure.


11. Bob Mar 24, 2008 at 14:46

Hee i just want to give u a big thank you for your fantastic railscast! I'm looking forward to the next episodes!


12. Peter De Berdt Mar 28, 2008 at 03:51

Although not the most elegant of solutions, but you can just patch the add method of the BufferedLogger in case you want to keep it.

Create a file custom_logger.rb in your initializers folder and paste the content of the pastie in it (it only puts pid in the log message in production mode, it's less ugly):
http://pastie.caboo.se/171954


13. Brian Jul 03, 2008 at 16:27

I've upgraded to Rails 2.1.0 and I can't get the logger to change, so I can't group by controller actions. Without that its really hard to make anything useful out of the log. I tried Peter's pastie code for Rails > 2.0 but Active record crashes with this code in my environment.rb
Any help would be great, because this looks like a great tool.


14. Willem van Bergen Jan 18, 2009 at 08:37

I am the author of request-log-analyzer (http://github.com/wvanbergen/request-log-analyzer/), an open-source command line tool to analyze production logs.

It is a bit more advanced than rawk and produces more detailed reports: http://wiki.github.com/wvanbergen/request-log-analyzer/sample-output

Maybe it can be of help if you are trying to find the bottlenecks in your application.


15. dsvfs Oct 12, 2009 at 21:35

 http://www.dunkkick.com/">cheap nike dunk sb shoes</a>
 http://www.dunkkick.com/mens-high-nike-dunk-sb-shoes-c-299.html">Discount Men's High Nike Dunk SB Shoes</a>
 http://www.dunkkick.com/mens-low-nike-dunk-sb-shoes-c-301.html">Men's Low Nike Dunk SB Shoes</a>


16. Gema Feb 19, 2010 at 22:15

O, yeah, this is that program what i need


17. Andrya Feb 25, 2010 at 11:43

I think you must kill your nod32


18. Viktor Feb 27, 2010 at 00:46

Okey, i find what i need


19. Viktoriya Mar 01, 2010 at 19:22

<a href="http://r01.ru\">russian</a>


20. Senyuha Mar 09, 2010 at 23:30

Hmm... It's very interesting design


21. Dasha Apr 08, 2010 at 00:17

I can't download program! Help!


22. Vitushka Apr 21, 2010 at 00:14

Hey! Can this program run from Win7?


23. Marksi Apr 22, 2010 at 05:16

There is no more good programmers. You are one of them


24. palani Jul 21, 2010 at 05:49

It is really a gud job!!. Keep on increasing my rails learning curve through RailsCasts. Thanks to Ryan Bats


25. Send flowers to Korea Jul 26, 2010 at 00:44

I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work.


26. optical fiber Cable Aug 01, 2010 at 23:59

I am very appreciate the issue that it can benefit to the low income guys, thanking for your sharing, it is wonderful.


27. solar collector solar water heater Aug 02, 2010 at 00:02

It's one of the most important facto to fix this time.


28. p90 workout Aug 12, 2010 at 09:18

I found your blog on Yahoo and I just wanted to say that I think your writing is simply stunning! Thanks again for providing this content for free.


29. cheap air jordans Aug 14, 2010 at 01:27

I just wanted to say that I think your writing is simply stunning! Thanks again for providing this content for free. It's very interesting design


30. supra tk society Aug 18, 2010 at 18:49

good job,good article


31. cool stuff Aug 25, 2010 at 02:14

very cool article ,like my cool stuff .very useful.thanks for sharing the article!


32. louis vuitton shoes Aug 26, 2010 at 20:55

Thanks for sharing your article. I really enjoyed it. I put a link to my site to here so other people can read it. My readers have about the same interets


33. snow boots Aug 31, 2010 at 00:33

It's really nice if you have logs spread out over a number of machines. It's easy enough to cat them together and send them to Rawk.


34. snow boots Aug 31, 2010 at 00:33

It's really nice if you have logs spread out over a number of machines. It's easy enough to cat them together and send them to Rawk.


35. Cheap Supra Shoes Sep 01, 2010 at 00:43

I really enjoy this perfect article and would like to have more friends notified of this website.


36. GHD Hair Straighteners Sep 01, 2010 at 00:43

Hope the writer could release more such articles


37. GHD Australia Sep 01, 2010 at 00:44

Great article


38. louis vuitton sunglasses Sep 01, 2010 at 22:40

Hi, good post, and awesome weblog you have here!
What’s this theme you use? Is it customized?
If customized can you please facilitate me the website of the company who designed it for you?
I would apreciate to have him/her do one for me also!

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