views:

304

answers:

5

I'd like to have a special part of administrate area which shows a list of pages/queries that was slow for the past week.

Is there a gem / plugin or other easy way to implement/automate such functionality for the Rails framework?

A: 

Yeah, it seems like a nice idea. I´ve never seen it before but I imagine you could just log the time each request takes to a DB; then a simple query will show you the slowest requests.

How you optimize your app depends entirely on your code; I guess there´s no silver bullet for that.

Seb
+3  A: 

Here's one example, and another and yet another. See google for even more.

MarkusQ
+1  A: 

Here are a couple of resources that may point you in the right direction:

http://blog.pluron.com/2008/02/memory-profilin.html http://austinentrepreneur.wordpress.com/2008/06/21/announcing-clientperf-simple-client-side-rails-performance/

Also Google is your friend ;)

vrish88
A: 

First thing that comes to mind: one could track execution time of the queries and if it passes some threshold which is considered normal (average maybe) it gets logged along with some profiling information (which is discarded otherwise).

It's might also be feasible to profile individual parts of the query (like data acquisition from db, logic and so on), then again compare the times against some averages.

One pitfall is that some pages/queries are bound to be processed significantly longer then others because of the difference in the amount of "work" they do. One would have to keep a whole lot of averages for different parts of the site / different types of queries in order to get rid of constant flow of normal queries that execute longer by design.

This is a very simple approach though, I'm sure there are better ways to do it.

frgtn
+4  A: 

http://www.newrelic.com/features.html

And a short screencast for RPM:

http://railslab.newrelic.com/2009/01/22/new-relic-rpm

P.S. I don't work for New Relic:)

Marcin Urbanski