<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Top 10 Ruby on Rails performance tips</title>
	<atom:link href="http://programmingzen.com/2007/02/10/top-10-ruby-on-rails-performance-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingzen.com/2007/02/10/top-10-ruby-on-rails-performance-tips/</link>
	<description>Meditations on programming, startups, and technology</description>
	<lastBuildDate>Thu, 10 May 2012 04:53:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: evan</title>
		<link>http://programmingzen.com/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-191</link>
		<dc:creator>evan</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://72.52.169.158/~antonioc/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-191</guid>
		<description>I have to take issue with most of these tips. Most of them are a lot of work for incremental benefit, many decrease maintainability, and some will affect your stability (e.g., patching the interpreter). Method dispatch is not really that slow. Is there some deployed app you are basing these suggestions on?</description>
		<content:encoded><![CDATA[<p>I have to take issue with most of these tips. Most of them are a lot of work for incremental benefit, many decrease maintainability, and some will affect your stability (e.g., patching the interpreter). Method dispatch is not really that slow. Is there some deployed app you are basing these suggestions on?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: josh</title>
		<link>http://programmingzen.com/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-192</link>
		<dc:creator>josh</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://72.52.169.158/~antonioc/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-192</guid>
		<description>I agree with Evan. While you claim not to advocate premature optimization, that&#039;s just what you are doing. &quot;Sometimes you may want to trade off just a bit of elegance and abstraction for speed.&quot; Then it&#039;s just a matter of degree.

Much of your advice consists of saying &quot;don&#039;t use Rails feature X&quot;. If you don&#039;t want to use Rails, then don&#039;t use Rails. I find it poor advice to try to turn Ruby on Rails into Java or PHP.</description>
		<content:encoded><![CDATA[<p>I agree with Evan. While you claim not to advocate premature optimization, that&#8217;s just what you are doing. &#8220;Sometimes you may want to trade off just a bit of elegance and abstraction for speed.&#8221; Then it&#8217;s just a matter of degree.</p>
<p>Much of your advice consists of saying &#8220;don&#8217;t use Rails feature X&#8221;. If you don&#8217;t want to use Rails, then don&#8217;t use Rails. I find it poor advice to try to turn Ruby on Rails into Java or PHP.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tyler</title>
		<link>http://programmingzen.com/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-193</link>
		<dc:creator>Tyler</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://72.52.169.158/~antonioc/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-193</guid>
		<description>I think these suggestions are fine and agree with a good number of them.  Antonio is simply telling readers about practices that can impact performance on high-volume websites.  It doesn&#039;t matter what framework you use - you&#039;re almost assured of needing to sacrifice code elegance for speed if your performance requirements are in the upper percentiles.  I&#039;d understand the objection if Antonio had said that all Rails programmers should avoid these features right from the start... but he didn&#039;t say that.</description>
		<content:encoded><![CDATA[<p>I think these suggestions are fine and agree with a good number of them.  Antonio is simply telling readers about practices that can impact performance on high-volume websites.  It doesn&#8217;t matter what framework you use &#8211; you&#8217;re almost assured of needing to sacrifice code elegance for speed if your performance requirements are in the upper percentiles.  I&#8217;d understand the objection if Antonio had said that all Rails programmers should avoid these features right from the start&#8230; but he didn&#8217;t say that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PJ Hyett</title>
		<link>http://programmingzen.com/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-194</link>
		<dc:creator>PJ Hyett</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://72.52.169.158/~antonioc/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-194</guid>
		<description>Then the question becomes at what point do you actually need to bother with any of these.

We receive ~12 million pageviews per month and go out of our way to write elegant and readable code at the expense of efficiency.</description>
		<content:encoded><![CDATA[<p>Then the question becomes at what point do you actually need to bother with any of these.</p>
<p>We receive ~12 million pageviews per month and go out of our way to write elegant and readable code at the expense of efficiency.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mazdak</title>
		<link>http://programmingzen.com/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-195</link>
		<dc:creator>Mazdak</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://72.52.169.158/~antonioc/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-195</guid>
		<description>josh, you are clearly overreacting. He is by no means suggesting that you should stop using Rails. He is just pointing out some tips that might help make things better. But I do agree with the points made about most of these optimizations being &quot;best practices&quot; rather than real optimizations. If MUST measure before optimizing, but it&#039;s good to keep things in the back of your mind as you code, e.g. not using too many ivars.</description>
		<content:encoded><![CDATA[<p>josh, you are clearly overreacting. He is by no means suggesting that you should stop using Rails. He is just pointing out some tips that might help make things better. But I do agree with the points made about most of these optimizations being &#8220;best practices&#8221; rather than real optimizations. If MUST measure before optimizing, but it&#8217;s good to keep things in the back of your mind as you code, e.g. not using too many ivars.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: big o</title>
		<link>http://programmingzen.com/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-196</link>
		<dc:creator>big o</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://72.52.169.158/~antonioc/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-196</guid>
		<description>i think the negative reactions here are, at base, a product of the fact that if you are really in a position to be needing to do these optimizations, you should probably know all these things anyway.  put another way: if you&#039;re not aware of most of these issues, maybe you shouldn&#039;t be in charge of optimizing a project that requires this much optimization.

Having said that, I do have some constructive comments:
 - The author is dead right about the speed of REXML.  REXML (in DOM-style mode, at least) is unforgivably slow if you&#039;re parsing large files (ditto for massive quantities of small ones).  If you can guarantee their well-formedness, Libxml is unbelievably fast.  If you can&#039;t, consider Hpricot&#039;s XML mode.  REXML&#039;s stream parser might be decent, haven&#039;t really used it.

- there&#039;s been some research to indicate using MemCache for sessions when you don&#039;t need it (if your session count is small) might actually be slower than SQLSessionStore.

- the &#039;use your database&#039; comment suggests stored procs but neglects to mention: optimize your indexes.  analyze your queries, figure out what keys you&#039;re using for your selections, and add appropriate indexes.  this will make a significant difference in a lot of cases.

finally: simplify.  Four out of five times I find that inefficiencies in an app are the result of overly complicated design.  It might very well be okay to use some crazy finder method like Foo.find_by_bar_and_mother_id_and_age_and_genetic_imperative(),
but it probably shouldn&#039;t be in a loop that executes 1,000 times.

Three cheers for the zen of software development.
-o</description>
		<content:encoded><![CDATA[<p>i think the negative reactions here are, at base, a product of the fact that if you are really in a position to be needing to do these optimizations, you should probably know all these things anyway.  put another way: if you&#8217;re not aware of most of these issues, maybe you shouldn&#8217;t be in charge of optimizing a project that requires this much optimization.</p>
<p>Having said that, I do have some constructive comments:<br />
 &#8211; The author is dead right about the speed of REXML.  REXML (in DOM-style mode, at least) is unforgivably slow if you&#8217;re parsing large files (ditto for massive quantities of small ones).  If you can guarantee their well-formedness, Libxml is unbelievably fast.  If you can&#8217;t, consider Hpricot&#8217;s XML mode.  REXML&#8217;s stream parser might be decent, haven&#8217;t really used it.</p>
<p>- there&#8217;s been some research to indicate using MemCache for sessions when you don&#8217;t need it (if your session count is small) might actually be slower than SQLSessionStore.</p>
<p>- the &#8216;use your database&#8217; comment suggests stored procs but neglects to mention: optimize your indexes.  analyze your queries, figure out what keys you&#8217;re using for your selections, and add appropriate indexes.  this will make a significant difference in a lot of cases.</p>
<p>finally: simplify.  Four out of five times I find that inefficiencies in an app are the result of overly complicated design.  It might very well be okay to use some crazy finder method like Foo.find_by_bar_and_mother_id_and_age_and_genetic_imperative(),<br />
but it probably shouldn&#8217;t be in a loop that executes 1,000 times.</p>
<p>Three cheers for the zen of software development.<br />
-o</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Allen</title>
		<link>http://programmingzen.com/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-197</link>
		<dc:creator>Ryan Allen</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://72.52.169.158/~antonioc/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-197</guid>
		<description>Why oh why have we stopped talking about patterns!</description>
		<content:encoded><![CDATA[<p>Why oh why have we stopped talking about patterns!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Carey</title>
		<link>http://programmingzen.com/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-198</link>
		<dc:creator>Mark Carey</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://72.52.169.158/~antonioc/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-198</guid>
		<description>Some of the suggestions are common sense (ie- don&#039;t initialize variables you don&#039;t need, besides it makes for ugly code), others are over the top (ie- patching the interpreter).

Your comment about using HTML neglects the fact that there are plugins that add rake tasks to pre-render your views to HTML to gain that optimization only in production mode.  There are other plugins to optimize your assets as well (ie- asset_packager).

Using non-standard versions of an interpreter is very unwise.  As the language changes and grows you are forced to maintain your patched version as the interpreter evolves or never upgrade.

One thing to keep in mind is that hardware is cheap and if you are driving the kind of traffic that would force you to sacrifice elegance for efficiency then you should look at adding more hardware to your deployment.  Using finders and filters are part of what makes Rails so powerful, their cost in performance is justified by the cheapness of hardware and the time saved in development and maintainability of the code.

Leveraging the DB is one optimization suggestion I fully support.  DB&#039;s are capable of doing some serious heavy lifting with things like views and stored procedures.  If you are writing an application that will always use a specific DB then it makes total sense to leverage the benefits of that DB.  However for the sake of maintainable code, it would be wise to keep the custom SQL out of the controller and in your model, with healthy and clear documentation.</description>
		<content:encoded><![CDATA[<p>Some of the suggestions are common sense (ie- don&#8217;t initialize variables you don&#8217;t need, besides it makes for ugly code), others are over the top (ie- patching the interpreter).</p>
<p>Your comment about using HTML neglects the fact that there are plugins that add rake tasks to pre-render your views to HTML to gain that optimization only in production mode.  There are other plugins to optimize your assets as well (ie- asset_packager).</p>
<p>Using non-standard versions of an interpreter is very unwise.  As the language changes and grows you are forced to maintain your patched version as the interpreter evolves or never upgrade.</p>
<p>One thing to keep in mind is that hardware is cheap and if you are driving the kind of traffic that would force you to sacrifice elegance for efficiency then you should look at adding more hardware to your deployment.  Using finders and filters are part of what makes Rails so powerful, their cost in performance is justified by the cheapness of hardware and the time saved in development and maintainability of the code.</p>
<p>Leveraging the DB is one optimization suggestion I fully support.  DB&#8217;s are capable of doing some serious heavy lifting with things like views and stored procedures.  If you are writing an application that will always use a specific DB then it makes total sense to leverage the benefits of that DB.  However for the sake of maintainable code, it would be wise to keep the custom SQL out of the controller and in your model, with healthy and clear documentation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://programmingzen.com/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-199</link>
		<dc:creator>David</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://72.52.169.158/~antonioc/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-199</guid>
		<description>Very sensible advice Antoni.</description>
		<content:encoded><![CDATA[<p>Very sensible advice Antoni.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dejan.dimic@gmail.com</title>
		<link>http://programmingzen.com/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-200</link>
		<dc:creator>dejan.dimic@gmail.com</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://72.52.169.158/~antonioc/2007/02/10/top-10-ruby-on-rails-performance-tips/#comment-200</guid>
		<description>I adore this kind of discussions.
It is always good to remind that the frameworks enable us to work fast but some time don’t produce optimize code. This compromise we made every programming day. Should we think about the speed while we build the application or should we first build than measure and then optimize. Like some philosopher said – it is all meter of equilibrium.

I don’t want to propagate my way of doing things but I feel the need to share some of mine experience in a general meaner. Developing real-time applications is mine domain for the last ten years. Every tick counts. On the other side the systems that we develop are too big with a lot of code, unnumbered classes and far to menu methods. Last time I check the source has approximately 0.5 Gb.
Usually I describe mine position as a flight control, kipping in mind the picture how the system operate and just know where to look.

While developing something you should always kip in mind that request are:
 - it should work as supposed to,
 - be able to find misbehaviors fast and precise,
 - you or somebody else will change this code in a six months time under very big pressure and should be able to understand fast what the class, method or system should work,
 - this peace of code could stay forever or could be replaced tomorrow with no implication on a rest of the system.

It is hard to make the right balance to all of these requirements, but finding the perfection is hard by its definition.

Some rules of tomb from experience:
 - think twice before you code,
 - design patterns are your best friend,
 - comment code as much as you could,
 - write unit tests for every system you build,
 - benchmark you code to find the bottlenecks and deal with them first,
 - premature optimization is the root of all evil.

Programming is an engineers discipline – we solve real problems in a real time for the real people and we enjoy doing it.

I am fully aver that I didn’t say anything new, but we oath to remind us from time to time about it.</description>
		<content:encoded><![CDATA[<p>I adore this kind of discussions.<br />
It is always good to remind that the frameworks enable us to work fast but some time don’t produce optimize code. This compromise we made every programming day. Should we think about the speed while we build the application or should we first build than measure and then optimize. Like some philosopher said – it is all meter of equilibrium.</p>
<p>I don’t want to propagate my way of doing things but I feel the need to share some of mine experience in a general meaner. Developing real-time applications is mine domain for the last ten years. Every tick counts. On the other side the systems that we develop are too big with a lot of code, unnumbered classes and far to menu methods. Last time I check the source has approximately 0.5 Gb.<br />
Usually I describe mine position as a flight control, kipping in mind the picture how the system operate and just know where to look.</p>
<p>While developing something you should always kip in mind that request are:<br />
 &#8211; it should work as supposed to,<br />
 &#8211; be able to find misbehaviors fast and precise,<br />
 &#8211; you or somebody else will change this code in a six months time under very big pressure and should be able to understand fast what the class, method or system should work,<br />
 &#8211; this peace of code could stay forever or could be replaced tomorrow with no implication on a rest of the system.</p>
<p>It is hard to make the right balance to all of these requirements, but finding the perfection is hard by its definition.</p>
<p>Some rules of tomb from experience:<br />
 &#8211; think twice before you code,<br />
 &#8211; design patterns are your best friend,<br />
 &#8211; comment code as much as you could,<br />
 &#8211; write unit tests for every system you build,<br />
 &#8211; benchmark you code to find the bottlenecks and deal with them first,<br />
 &#8211; premature optimization is the root of all evil.</p>
<p>Programming is an engineers discipline – we solve real problems in a real time for the real people and we enjoy doing it.</p>
<p>I am fully aver that I didn’t say anything new, but we oath to remind us from time to time about it.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

