I don’t usually worry about performance. Today, when a simple AJAX request sending back an empty body took 2 seconds to complete, I started digging.
Oddly, Firebug indicated over 2000 ms, while my log showed under a half-second. Since it’s on the same machine, there’s no way network issues can account for 1.5 seconds. I tried several avenues, and Marc-AndrĂ© suggested several possibilities before suggesting running it in production mode.
We were both suprised at the difference. Before / after:
Firebug: 1755 ms
Log: Completed in 0.47638 (2 reqs/sec) | Rendering: 0.00010 (0%) | DB: 0.15976 (33%) | 200 OK [http://standoutjobs.dev.com/****]
Firebug: 121 ms
Log: Completed in 0.11076 (9 reqs/sec) | Rendering: 0.00007 (0%) | DB: 0.06037 (54%) | 200 OK [http://standoutjobs.dev.com/****]]
A full order of magnitude! I’m used to logging and other debug overhead to have about a 10% performance hit, so this was very surprising.
If you’re like me, you have some personal web apps running in development mode. My first instinct was always to look at the logs, and see if there are some unnecessary requests being done, or anything that is taking far too much time. There’s also Marc-AndrĂ©’s tips for improving rails app performance. Still, those are a lot of work compared to the simple step of setting that production flag.
3 comments ↓
Hi Daniel, Sorry for the spam but you might want to read my post about web performance, I point to a nice presentation done by Steve Souders (Chief Performance Yahoo!).
(http://quebecvalley.com/2007/10/11/mysql-performance/)
you guess you are using too many associations and models for one method.
also you should benchmark the method, testing it twice isn’t really a measure a performance
Denis - thanks, I’ll check that out.
Heri - the results are consistent; running in development adds over a second per call. If you look at the Firebug and Mongrel reported times, it’s that discrepancy that’s most noticeable when coding.
There are a number of places where we could do eager loading to speed things up; but it may be premature optimization
Leave a Comment