<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cognition &#187; ruby on rails</title>
	<atom:link href="http://www.cognition.ca/tag/ruby-on-rails/feed" rel="self" type="application/rss+xml" />
	<link>http://www.cognition.ca</link>
	<description>Balls-in-the-air Entrepreneurship and Juggling.</description>
	<lastBuildDate>Tue, 14 Jun 2011 10:04:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Ruby on Rails causes Global Warming</title>
		<link>http://www.cognition.ca/2008/10/ruby-on-rails-causes-global-warming.html</link>
		<comments>http://www.cognition.ca/2008/10/ruby-on-rails-causes-global-warming.html#comments</comments>
		<pubDate>Sat, 01 Nov 2008 06:32:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[carbon]]></category>
		<category><![CDATA[entrepreneurs]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[ewaste]]></category>
		<category><![CDATA[global warming]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[lazyness]]></category>
		<category><![CDATA[philosophy]]></category>
		<category><![CDATA[politics]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[web2.0]]></category>

		<guid isPermaLink="false">http://www.cognition.ca/?p=32</guid>
		<description><![CDATA[I use a laptop. Which means, as I peck away at my keyboard in the waning hours of the evening, I can smell the slow charring of my wool pants (mixed with the redolent odor of singed leg hair) as the tiny fan embedded in my computer tries desperately to keep this multi-thousand-dollar device, from [...]]]></description>
			<content:encoded><![CDATA[<p>I use a laptop. Which means, as I peck away at my keyboard in the waning hours of the evening, I can smell the slow charring of my wool pants (mixed with the redolent odor of singed leg hair) as the tiny fan embedded in my computer tries desperately to keep this multi-thousand-dollar device, from melting into a pile of slag.</p>
<p>As a self-taught engineer, I tend to notice the glaringly-obvious &#8211; perhaps more than many of my well-educated peers. And there&#8217;s one obvious lesson in this &#8211; if solid state electronics are getting HOT, they&#8217;re <span style="text-decoration: line-through;">wasting</span> using a fair amount of power.</p>
<p><img class="alignright" style="border: 1px solid black; margin: 5px 10px;" title="Ewaste Burning" src="http://ewasteguide.info/system/files/images/3571_large.preview.jpg" alt="" width="283" height="212" />In a nuclear reactor somewhere out there, an atom died for the pixels on my screen. Another few drops of precious oil, or a few tons more gasified coal, were spilt for those extra minutes of Microsoft Word (or perhaps &#8220;Grand Theft Auto 4&#8243;).</p>
<p>Moore&#8217;s Law has shown us how the steady change of computing SPEED (doubling), and COST (halving), has reliably powered our advancing Information Age. Yet nothing in Moore&#8217;s Law has halted the seemingly inexorable increase in ENERGY requirements, of these most devious of machines.</p>
<p>This is not a problem that we&#8217;ve address head on &#8211; in our subsidized energy economy, there has been no real motivation to do so. In fact, as our dependency on computing infrastructure has deepened, we&#8217;ve made it WORSE. Here&#8217;s how it works:<span id="more-32"></span></p>
<blockquote><p>&#8220;Hey Jim, did you realize that these hard drives fail as they get older? And really reliable hard drives are WAY more expensive.&#8221;</p>
<p>&#8220;Wow! That SUCKS! Why don&#8217;t we just put TWO hard drives in every computer, and copy all the data to BOTH of them?&#8221;</p></blockquote>
<p>No joke. We&#8217;ve also done the same thing with (redundant) power supplies, and since all these extra disks and transformers are putting out more HEAT &#8211; we&#8217;ve had to install more AIR CONDITIONING, too. Oh, and in the REALLY high-end data centers, we&#8217;ve got at least one (sometimes two or more) Diesel Generators running at all times &#8211; just in CASE the power goes out.</p>
<p>As is typical of the world&#8217;s larger problems, the smartest folks haven&#8217;t done better &#8211; they&#8217;ve just done WORSE&#8230; in a more complicated way. Let&#8217;s take a look at programmers.</p>
<p>Writing software has changed a lot since we started this business. We&#8217;ve drifted from the &#8220;low-level&#8221; languages, up through the &#8220;high-level&#8221; languages, to things now rightly called &#8220;frameworks&#8221; that are too abstracted to be considered a language at all.</p>
<p>But along the way (with all this gratuitous computing power sitting around), we&#8217;ve gotten UNBELIEVABLY lazy. Here&#8217;s an example &#8211; it is, by no means, the only one:<!--more--></p>
<p>Ruby on Rails. A very popular framework, with some fairly typical problems.</p>
<p>Ruby is not, to start with, an <em>efficient</em> language. This means it doesn&#8217;t do a very good job of translating &#8220;high-level&#8221; code, into &#8220;low-level&#8221; machine code.</p>
<p><img class="alignright" style="border: 1px solid black; margin: 5px 10px;" title="Wires Burning" src="http://www.triplepundit.com/ppp022-Empa_open_burning.jpg" alt="" width="248" height="248" />Rails, as a framework, is intended to be <em>really</em> easy to use. Which means it does a LOT of stuff for you &#8211; much of which you don&#8217;t actually need done, in any given case.</p>
<p>Rails uses a database access pattern called &#8220;Active Record&#8221;. It&#8217;s pretty cool, actually &#8211; it encapsulates about 10 layers of abstraction, into a few easy-to-use commands.</p>
<p>Unfortunately, that encapsulation ignores most performance impacts. Also unfortunately, the implementation of that pattern &#8211; is not thread-safe.</p>
<p>Here&#8217;s where the laziness kicks in &#8211; rather than fixing the ActiveRecord implementation, or making ruby more efficient in general, someone wrote Mongrel.</p>
<p>What&#8217;s Mongrel? An extra web-serving layer, it simply manages a bunch of ruby instances, and hands http requests back and forth. It&#8217;s a workaround for the thread-safety problems we were mentioning above.</p>
<p>In software development, it&#8217;s called a &#8220;Kludge&#8221;. In human society, it&#8217;s called a &#8220;Rat Race&#8221;. (We all drive SUVs, even when we object to them environmentally, because we need to be safe &#8211; safe in case someone ELSE driving an SUV crashes INTO us. Are you starting to appreciate the irony?)</p>
<blockquote><p>&#8220;So what,&#8221; I can hear you saying, &#8220;Buying more hardware is cheaper than fixing a whole language, right?&#8221;</p>
<p>Yes, it is. And that&#8217;s the problem.</p></blockquote>
<p><img class="alignright" style="border: 1px solid black; margin: 5px 10px;" title="Young Children work Your E Waste" src="http://ewasteguide.info/system/files/images/3643_large.preview.jpg" alt="" width="231" height="307" />Because there are other, more insidious, global impacts of this wasteful computing philosophy. If you need a wickedly fast CPU and a few gigs of Ram to run a Ruby on Rails server, might as well turf out the old servers, right? Those old servers end up as e-waste in developing nations. (HEADLINE: &#8220;Lazy coding kills children in the third world&#8221;)&#8230;</p>
<p>Now, I&#8217;m not espousing a return to the good-ol-days of hand-coded assembler, or even web apps written in pure C. But I&#8217;ve managed 10,000 http requests per second on a single server (yes, including DB) &#8211; simply by taking the extra day or so to tune the database, install some byte-code cacheing &#8211; oh, and not running RoR.</p>
<p>Even if you don&#8217;t care about the <a href="http://www.mindfully.org/WTO/Computers-Go-To-Die23nov02.htm">12 year old kids dying in Thailand</a> while they bake your discarded motherboard over a camel-dung campfire &#8211; at least think about the abuse you&#8217;re putting your electrons through.</p>
<p>(Editor&#8217;s note: Many thousands of electrons were tortured in the writing of this blog post. And yes, this is deliberately provocative link-bait for my overly-zealous RoR-fanatic friends. Which doesn&#8217;t make it any less true.)</p>
<span class="akst_link"><a href="http://www.cognition.ca/?p=32&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_32"  class="akst_share_link">Share This</a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.cognition.ca/2008/10/ruby-on-rails-causes-global-warming.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

