#97
Mar 17

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)

12 comments:

QuBiT Mar 17, 2008 at 03:24

Hi,

really nice and handy, waiting for more ;-)


philippe Mar 17, 2008 at 07:13

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


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.


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 ;-)


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 ;)


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.


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.


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.


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. ;)


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.


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!


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

Add your comment:

(required)

(not displayed)

(SKIP THIS ONE)


(required)

subscribe:
sponsored by:
if you want to help:
required:
Get Quicktime Player