Rails performance expert Dr. Stefan Kaes takes a look at the most common performance issues in your Rails applications and what to do about them. Advice is given regarding benchmarking, choosing a session container, caching results of expensive computations, optimizing database queries and working effectively with view helpers.
Read: A Look at Common Performance Problems in Rails
Community comments
Real World Experiences?
by Obie Fernandez,
Updated article
by Obie Fernandez,
good article
by Michael Kovacs,
Very Useful!
by Geoffrey Grosenbach,
Great Practicle Information
by Ben Askins,
memcache-client author
by Eric Hodel,
Getting Memcache-Client to work with Sessions
by Adam Michaels,
Re: Getting Memcache-Client to work with Sessions
by chris hulbert,
Re: Getting Memcache-Client to work with Sessions
by Geoffrey Grosenbach,
32 percent...
by chris hulbert,
optimizing queries...
by Boing Boinger,
'Include' can improve performance?
by Zhenbo Hu,
tell ActiveRecord what you don not want to select from database
by rafael magana,
Real World Experiences?
by Obie Fernandez,
Your message is awaiting moderation. Thank you for participating in the discussion.
We'd love to hear from any folks putting Stefan's suggestions into practice.
Updated article
by Obie Fernandez,
Your message is awaiting moderation. Thank you for participating in the discussion.
The initial publication of this article and related feed snippets incorrectly identified Stefan as a member of the Rails core team. This was my editorial mistake and I apologize for any confusion caused.
good article
by Michael Kovacs,
Your message is awaiting moderation. Thank you for participating in the discussion.
Thanks Stefan for this article. Lots of good information here that will come in handy once I'm ready to tune for perf.
Very Useful!
by Geoffrey Grosenbach,
Your message is awaiting moderation. Thank you for participating in the discussion.
Very practical and useful. Thanks!
Great Practicle Information
by Ben Askins,
Your message is awaiting moderation. Thank you for participating in the discussion.
For me this article is a lamp in the dark pointing out little obstacles I wouldn't otherwise have noticed. Thanks Stefan.
memcache-client author
by Eric Hodel,
Your message is awaiting moderation. Thank you for participating in the discussion.
Bob Cottrell wrote memcache-client, I just packaged it up and released it.
Getting Memcache-Client to work with Sessions
by Adam Michaels,
Your message is awaiting moderation. Thank you for participating in the discussion.
Does anyone have a link to a tutorial or have an idea how to get Memcache-Client to work with Rails sessions seeing as its the prefered ruby client.
32 percent...
by chris hulbert,
Your message is awaiting moderation. Thank you for participating in the discussion.
I just spent today putting into practice I just spent today putting into practice most of the ideas suggested here, especially caching using class variables, memcached sessions, and not using slow helpers.
With extensive testing, my production server now serves up pages 31.8% faster!
63.8 seconds versus 93.5 to complete a test suite i created.
Very happy :)
Chris - splinter.com.au
Re: Getting Memcache-Client to work with Sessions
by chris hulbert,
Your message is awaiting moderation. Thank you for participating in the discussion.
Memcached server:
www.danga.com/memcached/
Memcached client:
rubyforge.org/projects/rctools
Hooking it up in rails:
wiki.rubyonrails.com/rails/pages/HowtoChangeSes...
Re: Getting Memcache-Client to work with Sessions
by Geoffrey Grosenbach,
Your message is awaiting moderation. Thank you for participating in the discussion.
I did a straight copy and tweak of the Rails MemcacheStore to work with memcache-client, here:
topfunky.net/svn/plugins/db_memcache_store/lib/...
optimizing queries...
by Boing Boinger,
Your message is awaiting moderation. Thank you for participating in the discussion.
consider cache-fu. little in the way of docs at this point, but it's a good activerecord cache...
errtheblog.com/static/pdfs/memcached.pdf
'Include' can improve performance?
by Zhenbo Hu,
Your message is awaiting moderation. Thank you for participating in the discussion.
I tried, but it seems no performance improvement at all.
tell ActiveRecord what you don not want to select from database
by rafael magana,
Your message is awaiting moderation. Thank you for participating in the discussion.
some days ago I made a patch to add a :noselect option to use with the ActiveRecord::find method:
let's say you have a table with 5 columns, and you want to select 4 of them:
User.first(:select => "col_1, col_2, col_3, col_4")
with my patch you can do this:
User.first(:noselect => "col_5")
maybe it's not a big improvement in speed but it can help in tables with a bunch of columns. well that's it.
here's the post where I explain a little bit more how it works and the link to the patch: bit.ly/cIt4pa