Topic: Performance Issue... Where is the time gone?

Hi everyone,

I've been working for a few weeks on a Rails project (I am sort of a beginner... so it was longer that it should have!).
I am now testing my app in its production environment whil keeping it closed to other users, and I am facing terrible performance problems!

I've used Rawk to identify the bottlenecks in my app, and I was able to identify that many request take "infinite" time to be treated, like this one :

Completed in 14.74947 (0 reqs/sec) | Rendering: 0.92342 (6%) | DB: 1.57776 (10%) | 200 OK

The DB is bad... I know, and the rendering isn't good either, but how come I get a Completed time in 14.8 sec, with 1.6 in DB and 0.9 in renderding? Where are the 12 remaining  seconds?

Re: Performance Issue... Where is the time gone?

14.74977 seconds is the total time spent on the Action which includes time spent in the view and DB.  The remaining 12 seconds is being spent on just your Action code. 

If it's taking that long, my guess is that you're making a call over the internet for a large dataset and/or your connection is slow.  Just a guess since I had that problem a long time ago.  I got around it by putting a timeout, for example Timeout::timeout(1.5) for 1.5 seconds.  If the request wasn't processed in 1.5 seconds I killed the action and gave the user cached values.

Re: Performance Issue... Where is the time gone?

Thanks Vince, that's helpful! I think I'm gonna use the Timeout!

Thanks again!

Re: Performance Issue... Where is the time gone?

The timeout function is a good thing to add. But are you using fcgi. If so your app might be booting up for some of these requests. Slow down to that degree is very unusual unless working with very very large data-sets or complex requests.