5067 comments
2220 subscribers
4798 on Twitter
Subscribe! Feed reader E-mail

Negative optimization

Checking on one of my projects (a Ruby on Rails survey site), I realized that it was running painfully slowly, taking 30 seconds to render a page.

The first thing I checked was memory. I was on a 256MB slice at Rackspace Cloud. Was the server running out of memory and swapping to disk? I put in the recommended settings for Apache+Passenger+Rails on 256MB:

RailsSpawnMethod smart
PassengerUseGlobalQueue on
PassengerMaxPoolSize 2
PassengerPoolIdleTime 0
PassengerMaxRequests 1000
RailsAppSpawnerIdleTime 0
PassengerStatThrottleRate 5

The website was still crawling. I reviewed the logs and found that ActiveRecord was taking a while. The Internet had a few performance optimization tips, so I checked out the survey controller to see if I could improve performance by preloading information.

As it turned out, I was already preloading information. So I tried turning off preloading by removing the :include directives for my queries.

The system went back to a decent speed.

You see, I’d been working with lots of associations, and eager loading had probably resulted in a gazillion rows in my result set.

Moral lesson: Test your system before and after you put in something to improve the performance, because you just might be making your performance worse. ;)

Oh well. Live and learn!

2011-06-07 Tue 16:19

Short URL: http://sachachua.com/blog/p/22288

Comment, share a thought, ask a question...

Please comment as you, not your organization.





 

On This Day...

  • 2010: Weekly review: Week ending June 7, 2010 — What a week! W- and I spent the entire weekend woodworking. I’m tired, happy, and looking forward to the next [...]
  • 2009: Preventive maintenance and the Goldtouch Go! keyboard — Other people might go to a massage therapist to relax. I go so that I can spend an hour and [...]
  • 2008: Emacs Gnus: Filter Spam — (draft for an upcoming book called Wicked Cool Emacs) Ah, spam, the bane of our Internet lives. There is no completely reliable [...]
  • 2005: Adding an arbitrary extension to your planner files — Do you want all of your planner files to have a TXT extension so that they’ll be searched by tools such [...]
  • 2005: Software Freedom Day — 1. Why Sept. 10? What’s the significance of that date? Hehe… well, that wss the day that Open Minds (now the [...]
  • 2003: Extreme programming in the classroom — - http://www.compapp.dcu.ie/~cdaly/research/confs/02/sigcse.html (very useful) - http://ecommerce.ncsu.edu/people/williams.html - http://csis.pace.edu/~bergin/XPWorkshop/tutorial.html Thanks to Dominique Cimafranca for the heads-up! =)
  • 2003: Found an apartment! — I’ll be staying at Dormitoryana on B. Gonzales St. – it’s a girls’ dorm, pretty nice, lots of greenery, and quite [...]
  • 2003: Christian Manoloto — http://www.geocities.com/among2004/