<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Motion Standing Still</title>
	
	<link>http://www.motionstandingstill.com</link>
	<description>high performance ruby on rails</description>
	<pubDate>Wed, 08 Jul 2009 02:02:40 +0000</pubDate>
	
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/motionstandingstill" type="application/rss+xml" /><item>
		<title>Silence = Stupid Busy</title>
		<link>http://feedproxy.google.com/~r/motionstandingstill/~3/wkKklI4agZc/</link>
		<comments>http://www.motionstandingstill.com/silence-stupid-busy/2009-04-26/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 01:08:43 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
		
		<category><![CDATA[Miscellaneous]]></category>

		<category><![CDATA[mod_rails]]></category>

		<category><![CDATA[nginx]]></category>

		<category><![CDATA[passenger]]></category>

		<category><![CDATA[projectx]]></category>

		<category><![CDATA[ruby enterprise edition]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=237</guid>
		<description><![CDATA[So, um yeah, it&#8217;s been a little while since my last blog entry.  This is to say that I&#8217;m still here, things have been too hectic but I&#8217;m starting to get a handle on everything again.
I was already quite busy when everything stepped up a couple of gears around February due to going into business [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">So, um yeah, it&#8217;s been a little while since my last blog entry.  This is to say that I&#8217;m still here, things have been too hectic but I&#8217;m starting to get a handle on everything again.</p>
<p style="text-align: justify;">I was already quite busy when everything stepped up a couple of gears around February due to going into business with  <a href="http://projectx.co.nz/site/staff" target="_blank">ProjectX</a> and thus my friend <a href="http://twitter.com/johnclegg" target="_blank">John Clegg</a>.  I&#8217;m slowly taking over the back end of the business while he focuses on the front end.  Essentially I get more toys and larger projects to play with :-)</p>
<p style="text-align: justify;">To be realistic I reckon I&#8217;ll only get out a blog entry once every couple of weeks at this stage - which will be hard as there&#8217;s an increasing amount to blog about.  Top of my list is <a href="http://nginx.net/" target="_blank">Nginx</a> with the recently updated <a href="http://blog.phusion.nl/2009/04/18/phusion-passenger-221-released/" target="_blank">Phusion Passenger</a> and <a href="http://www.rubyenterpriseedition.com/" target="_blank">Ruby Enterprise Edition</a> which is powering our new <a href="http://www.redmine.org/" target="_blank">Redmine</a> server.</p>
<p>Stay tuned.</p>


<p>No related posts.</p><img src="http://feeds.feedburner.com/~r/motionstandingstill/~4/wkKklI4agZc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/silence-stupid-busy/2009-04-26/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.motionstandingstill.com/silence-stupid-busy/2009-04-26/</feedburner:origLink></item>
		<item>
		<title>Wellington based website optimisation group</title>
		<link>http://feedproxy.google.com/~r/motionstandingstill/~3/bNjKm8sm-qI/</link>
		<comments>http://www.motionstandingstill.com/wellington-based-website-optimisation-group/2009-02-11/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 10:09:06 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
		
		<category><![CDATA[Features]]></category>

		<category><![CDATA[Miscellaneous]]></category>

		<category><![CDATA[optimisation]]></category>

		<category><![CDATA[user group]]></category>

		<category><![CDATA[welloptimised]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=232</guid>
		<description><![CDATA[Something I get asked about a bit and which gets suggested for WellRailed meetings is the topic of optimisation, in particular using MemCache and infrastructure design.  While someone could present on these and other relevant topics within the bounds of Ruby on Rails I think it would be way more sensible to free presentors from [...]


Related posts:<ol><li><a href='http://www.motionstandingstill.com/performance-optimisation-through-named_scope/2008-09-11/' rel='bookmark' title='Permanent Link: Performance optimisation through named_scope'>Performance optimisation through named_scope</a> <small>I recently gave a presentation about using named_scopes to WellRailed...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Something I get asked about a bit and which gets suggested for <a href="http://groups.google.com/group/wellrailed" target="_blank">WellRailed</a> meetings is the topic of optimisation, in particular using MemCache and infrastructure design.  While someone could present on these and other relevant topics within the bounds of Ruby on Rails I think it would be way more sensible to free presentors from being tied to any one particullar framework, language or whatever.  This would interest a greater selection of people thus providing increased benefit to everyone.</p>
<p style="text-align: justify;">So with that in mind I&#8217;ve setup a new google group, <a href="http://groups.google.com/group/welloptimised" target="_blank">WellOptimised</a>.  If there is enough interest I&#8217;ll organise meetings for those here in Wellington.</p>
<p style="text-align: justify;">If you are interested pop along via the above link and introduce yourself.</p>


<p>Related posts:<ol><li><a href='http://www.motionstandingstill.com/performance-optimisation-through-named_scope/2008-09-11/' rel='bookmark' title='Permanent Link: Performance optimisation through named_scope'>Performance optimisation through named_scope</a> <small>I recently gave a presentation about using named_scopes to WellRailed...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/motionstandingstill/~4/bNjKm8sm-qI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/wellington-based-website-optimisation-group/2009-02-11/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.motionstandingstill.com/wellington-based-website-optimisation-group/2009-02-11/</feedburner:origLink></item>
		<item>
		<title>Spandex Memcache Store is now in Rails 2.3</title>
		<link>http://feedproxy.google.com/~r/motionstandingstill/~3/8de-6t6wu3s/</link>
		<comments>http://www.motionstandingstill.com/spandex-memcache-store-is-now-in-rails-23/2009-02-04/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 00:36:06 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
		
		<category><![CDATA[Features]]></category>

		<category><![CDATA[Memcache]]></category>

		<category><![CDATA[ruby on rails]]></category>

		<category><![CDATA[spandex mem cache store]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=228</guid>
		<description><![CDATA[Just a quick note to say that the local cache functionality of my Spandex Memcache Store Plugin has been included in Ruby on Rails 2.3 RC1.  After I released the plugin I was asked to submit a patch to Rails Edge adding it&#8217;s functionality - which I did over my Christmas break.  My changes have [...]


Related posts:<ol><li><a href='http://www.motionstandingstill.com/spandex-mem-cache-store/' rel='bookmark' title='Permanent Link: Spandex Mem Cache Store'>Spandex Mem Cache Store</a> <small>taken from the plugin&#8217;s README Description A enhanced version of...</small></li><li><a href='http://www.motionstandingstill.com/how-to-reduce-your-memcache-reads/2008-11-14/' rel='bookmark' title='Permanent Link: How to reduce your memcache reads'>How to reduce your memcache reads</a> <small>Several months back I presented at WellRailed on using Memcache...</small></li><li><a href='http://www.motionstandingstill.com/starting-simple-with-rails-caching/2008-11-27/' rel='bookmark' title='Permanent Link: Starting simple with Rails caching'>Starting simple with Rails caching</a> <small>So, you’ve launched your website and increasingly people are actually...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Just a quick note to say that the local cache functionality of my <a href="http://github.com/terrcin/spandex_mem_cache_store/tree/master" target="_blank">Spandex Memcache Store Plugin</a> has been included in <a href="http://weblog.rubyonrails.org/2009/2/1/rails-2-3-0-rc1-templates-engines-rack-metal-much-more" target="_blank">Ruby on Rails 2.3 RC1</a>.  After I released the plugin I was asked to submit a patch to Rails Edge adding it&#8217;s functionality - which I did over my Christmas break.  My changes have subsequently been re-factored a bit, decoupling the local cache functionality from the MemCacheStore class and moving it to being a wrapper around whatever caching store is used.  Hurray for open source!</p>
<p>The plugin is still useful as I didn&#8217;t submit it&#8217;s session caching changes to Rails - essentially using Rails.cache for session storage rather than establishing a second connection to MemCache.  This also benefits from the local cache changes.</p>
<p>Where next?  In the next week or so I plan on updating the plugin by removing the local cache functionality to prevent any conflicts with Rails 2.3 when it&#8217;s released.</p>
<p>After that, I&#8217;m planning on working through the list of changes detailed under <em>Future Plans</em> in the <a href="http://github.com/terrcin/spandex_mem_cache_store/blob/402a216f1a982d2eaacb2169802a9a41708366fb/README" target="_blank">plugins readme</a>, also listed below.</p>
<ul>
<li>TESTS! (I wrote a bunch for the patch, just need to do that for the remaining session changes)</li>
<li>Make this a Gem</li>
<li>Conditional caching</li>
<li>Multi-Get</li>
<li>Dynamic key helpers</li>
<li>Make the code more awesome</li>
</ul>


<p>Related posts:<ol><li><a href='http://www.motionstandingstill.com/spandex-mem-cache-store/' rel='bookmark' title='Permanent Link: Spandex Mem Cache Store'>Spandex Mem Cache Store</a> <small>taken from the plugin&#8217;s README Description A enhanced version of...</small></li><li><a href='http://www.motionstandingstill.com/how-to-reduce-your-memcache-reads/2008-11-14/' rel='bookmark' title='Permanent Link: How to reduce your memcache reads'>How to reduce your memcache reads</a> <small>Several months back I presented at WellRailed on using Memcache...</small></li><li><a href='http://www.motionstandingstill.com/starting-simple-with-rails-caching/2008-11-27/' rel='bookmark' title='Permanent Link: Starting simple with Rails caching'>Starting simple with Rails caching</a> <small>So, you’ve launched your website and increasingly people are actually...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/motionstandingstill/~4/8de-6t6wu3s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/spandex-memcache-store-is-now-in-rails-23/2009-02-04/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.motionstandingstill.com/spandex-memcache-store-is-now-in-rails-23/2009-02-04/</feedburner:origLink></item>
		<item>
		<title>Setting up Postgres + Postgis on OSX</title>
		<link>http://feedproxy.google.com/~r/motionstandingstill/~3/Q8kr9uSQPFo/</link>
		<comments>http://www.motionstandingstill.com/setting-up-postgres-postgis-on-os/2008-12-18/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 23:22:49 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
		
		<category><![CDATA[Database]]></category>

		<category><![CDATA[Features]]></category>

		<category><![CDATA[gem]]></category>

		<category><![CDATA[install]]></category>

		<category><![CDATA[macports]]></category>

		<category><![CDATA[osx]]></category>

		<category><![CDATA[postgis]]></category>

		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=217</guid>
		<description><![CDATA[I've just installed Postgresql for the first time on my MacBook - it was a pain and wasn't as simple as it should have been.  This is what I did to get it working.


Related posts:<ol><li><a href='http://www.motionstandingstill.com/setting-up-a-resumable-remote-login-to-ubuntu-with-vnc/2008-10-13/' rel='bookmark' title='Permanent Link: Setting up a resumable remote login to ubuntu with vnc'>Setting up a resumable remote login to ubuntu with vnc</a> <small>I&#8217;ve changed my home server from Centos 5.1 (32bit) to...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Even though I&#8217;m stupidly busy with my current work I&#8217;ve started getting ready for my next gig.  As this has ment installing Postgresql on my Macbook for the first time I thought I&#8217;d quickly share the solution to the pain I went through in getting it to work.</p>
<p style="text-align: justify;">I received two suggestions for the &#8216;best install method&#8217;, firstly MacPorts and then later pre-compiled dmg&#8217;s from <a href="http://www.kyngchaos.com/wiki/software:postgres" target="_blank">Kyng Chaos</a>.  I already use ports extensively making that choice easy for me - I like being able to  uninstall things if they don&#8217;t work to well and was concerned the dmg option wouldn&#8217;t allow me to.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> port <span style="color: #c20cb9; font-weight: bold;">install</span> postgresql83 postgresql83-doc postgresql83-server postgis</pre></div></div>

<p style="text-align: justify;">I then added the following to my path in ~/.zshrc so I could actually run things</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>postgresql83<span style="color: #000000; font-weight: bold;">/</span>bin</pre></div></div>

<p style="text-align: justify;">and started the server.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> launchctl load <span style="color: #660033;">-w</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchDaemons<span style="color: #000000; font-weight: bold;">/</span>org.macports.postgresql83-server.plist</pre></div></div>

<p style="text-align: justify;">All seemed to be fine and dandy as I could connect with <a href="http://www.pgadmin.org/" target="_blank">pgAdmin</a>.  I quickly discovered that I needed to create a user with the same login as my osx login when I tried creating a test db.</p>
<p style="text-align: justify;">Next I tried restoring my client&#8217;s db dump and it barfed big time.  As I&#8217;ll be working on some mapping software I&#8217;d installed the PostGIS package which seems to have failed to link up with Postgres properly.   I was getting the follow missing library error:</p>
<blockquote style="text-align: justify;"><p>could not load library /usr/lib/postgresl/liblwgeom.so.1.3</p></blockquote>
<p style="text-align: justify;">Obviously it&#8217;s looking in the wrong place for a start, so I setup a LIBDIR export in my profile to get over that problem and restarted the server.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LIBDIR</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>postgresql83</pre></div></div>

<p style="text-align: justify;">That still didn&#8217;t solve the problem though as I don&#8217;t have a file by that name on my system, I do however have liblwgeom.1.3.so which looked to be the same thing.  Pretty annoying, but easily solved with a symlink.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>postgresql83
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-snf</span> liblwgeom.1.3.so liblwgeom.so.1.3</pre></div></div>

<p style="text-align: justify;">Then the backup restored like a chalm.</p>
<p style="text-align: justify;">To get Rails talking to Postgresql I needed to install the postgres adapter gem appropriately called &#8216;postgres&#8217;.  I didn&#8217;t expect that to work straight off though as I&#8217;d installed postgresql with ports and the gem by default would be looking in the wrong place for it.  I was correct, but I also received an additional error complaining about the architechture not being specified - I needed to tell it I wanted i386.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #007800;">ARCHFLAGS</span>=<span style="color: #ff0000;">&quot;-arch i386&quot;</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> postgres <span style="color: #660033;">--</span> <span style="color: #660033;">--with-pgsql-include-dir</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>postgresql83l <span style="color: #660033;">--with-pgsql-lib-dir</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>postgresql83<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p style="text-align: justify;">I gropped around for a bit trying to figure out the correct way of letting it know and eventually found the above solution on <a href="http://codesnippets.joyent.com/posts/show/1441" target="_blank">code snippets</a>.</p>


<p>Related posts:<ol><li><a href='http://www.motionstandingstill.com/setting-up-a-resumable-remote-login-to-ubuntu-with-vnc/2008-10-13/' rel='bookmark' title='Permanent Link: Setting up a resumable remote login to ubuntu with vnc'>Setting up a resumable remote login to ubuntu with vnc</a> <small>I&#8217;ve changed my home server from Centos 5.1 (32bit) to...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/motionstandingstill/~4/Q8kr9uSQPFo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/setting-up-postgres-postgis-on-os/2008-12-18/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.motionstandingstill.com/setting-up-postgres-postgis-on-os/2008-12-18/</feedburner:origLink></item>
		<item>
		<title>Yep, the blog new looks better.</title>
		<link>http://feedproxy.google.com/~r/motionstandingstill/~3/jlFynNgl_E0/</link>
		<comments>http://www.motionstandingstill.com/yep-the-blog-new-looks-better/2008-11-30/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 04:39:41 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
		
		<category><![CDATA[Miscellaneous]]></category>

		<category><![CDATA[minify]]></category>

		<category><![CDATA[theme]]></category>

		<category><![CDATA[yslow]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=207</guid>
		<description><![CDATA[The look and format of this here my blog has just undergone a much delayed overhaul.
Since I occasionally have quite a bit to say, like in my previous entry or this one about where business logic should reside, I&#8217;m now only showing excerpts on the index page rather than whole entries.  I&#8217;ve also gone though [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">The look and format of this here my blog has just undergone a much delayed overhaul.</p>
<p style="text-align: justify;">Since I occasionally have quite a bit to say, like in my <a href="http://www.motionstandingstill.com/starting-simple-with-rails-caching/2008-11-27/" target="_blank">previous entry</a> or this one about where <a href="http://www.motionstandingstill.com/i-dont-use-foreign-key-constraints-with-rails/2008-10-17/" target="_blank">business logic should reside</a>, I&#8217;m now only showing excerpts on the index page rather than whole entries.  I&#8217;ve also gone though and added in a couple of helpful plugins such as auto suggesting related posts and easy social bookmarking.  My next step is to change the source code syntax highlighting css - I&#8217;ll probably just use the Textmate bundle in Textmate.</p>
<p style="text-align: justify;">Currently the homepage <a href="http://developer.yahoo.com/yslow/" target="_blank">ySlow</a> score is 79, I can get this to 85 if I concatenate and minify the css as doing this reduces size and number of requests for empty caches.  This hasn&#8217;t happened yet as it&#8217;ll require a bit of hand tweaking due to not working out of the box.</p>
<p style="text-align: justify;">Overall I&#8217;ve gone for a more clean, simple and wider look by using <a href="http://themeshaper.com/acamas-theme-clarity-elegance-power/" target="_blank">Acamas</a> which is based on the opensource <a href="http://themeshaper.com/thematic-for-wordpress/" target="_blank" class="broken_link">Thematic framework</a>.  It looks great on a Mac, pretty good under Windows and terrible in IE6.  If you experience any problems, in particullar with the rss feed (now thru feedburner.com) please drop me a line.</p>
<p style="text-align: justify;"><strong>Update:</strong> I&#8217;ve gotten the ySlow score up to 90 now as the css is contenanted and minified plus the sidebar images are now being hosted locally allowing proper expires headers.  With the css files I&#8217;d simply been adding them together in the wrong order.  There is still a problem with <a href="http://developer.yahoo.net/blog/archives/2007/07/high_performanc_6.html" target="_blank">css expressions</a> though, but this will go away when I drop the syntax highlighting plugin - further boosting my yScore.</p>


<p>No related posts.</p><img src="http://feeds.feedburner.com/~r/motionstandingstill/~4/jlFynNgl_E0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/yep-the-blog-new-looks-better/2008-11-30/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.motionstandingstill.com/yep-the-blog-new-looks-better/2008-11-30/</feedburner:origLink></item>
		<item>
		<title>Starting simple with Rails caching</title>
		<link>http://feedproxy.google.com/~r/motionstandingstill/~3/2_JlCz93-yU/</link>
		<comments>http://www.motionstandingstill.com/starting-simple-with-rails-caching/2008-11-27/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 22:16:41 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
		
		<category><![CDATA[Features]]></category>

		<category><![CDATA[Memcache]]></category>

		<category><![CDATA[caching]]></category>

		<category><![CDATA[expire]]></category>

		<category><![CDATA[keys]]></category>

		<category><![CDATA[ruby on rails]]></category>

		<category><![CDATA[scaling]]></category>

		<category><![CDATA[simple]]></category>

		<category><![CDATA[stale data]]></category>

		<category><![CDATA[sweeper]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=195</guid>
		<description><![CDATA[So, you’ve launched your website and increasingly people are actually using it! Congratulations. Money is probably tight and your server(s) are starting to feel the strain but you can’t buy more - people get turned off by slow responding sites and traffic is $$. What do do?


Related posts:<ol><li><a href='http://www.motionstandingstill.com/spandex-memcache-store-is-now-in-rails-23/2009-02-04/' rel='bookmark' title='Permanent Link: Spandex Memcache Store is now in Rails 2.3'>Spandex Memcache Store is now in Rails 2.3</a> <small>Just a quick note to say that the local cache...</small></li><li><a href='http://www.motionstandingstill.com/be-careful-how-you-count/2008-09-12/' rel='bookmark' title='Permanent Link: Be careful how you count in Rails'>Be careful how you count in Rails</a> <small>I&#8217;ve just encountered this problem yet again effecting code I&#8217;m...</small></li><li><a href='http://www.motionstandingstill.com/i-dont-use-foreign-key-constraints-with-rails/2008-10-17/' rel='bookmark' title='Permanent Link: I don&#8217;t use Foreign Key Constraints with Rails'>I don&#8217;t use Foreign Key Constraints with Rails</a> <small>A couple of months back we had Nigel talking at...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">So, you&#8217;ve launched your website and increasingly people are actually using it!  Congratulations. Money is probably tight and your server(s) are starting to feel the strain but you can&#8217;t buy more - people get turned off by slow responding sites and traffic is $$.  What do do?</p>
<p style="text-align: justify;">You&#8217;ve noticed that your app is doing a lot of repetitive work - calculating and showing the same data over and over again.  This doesn&#8217;t fit with your adherence to DRY principles at all.  If you cached repetitive responses your servers could give you way more bang for you buck - and it would only cost your time.</p>
<p style="text-align: justify;">You are about to embark on an exciting journey fraught with hidden dangers, so let me prepare you - cheesy I know but hey.</p>
<p style="text-align: justify;">First, you have actually done some code optimisation haven&#8217;t you?  Stopped using the default mysql config?  Checked your slow query log?  Used pl_analyise to parse your production logs?  Fixed the popular, but slow actions?  Done some eager loading so you get everything in a couple of hits from mysql rather than many many many little hits as your views render?  When you dream you see log tailing in the background?  Minified your javascript and css?  Static assets have expire headers?  Don&#8217;t have too many Mongrels running?  Sessions are stored in MemCache? Go do all that if you haven&#8217;t and only come back here if this are still too slow.  Oh and try to get your yslow score above 75.</p>
<p style="text-align: justify;">Note: I&#8217;m assuming that you have read a bit about caching in Rails already and have had a play, reading fragments from actions etc&#8230;  If not try googling as there are a number of great articles on it, the Agile book is probably a good start too.</p>
<p style="text-align: justify;"><strong>Start at the end</strong></p>
<p style="text-align: justify;">Instead of just saying &#8216;do this awesome thing&#8217; I&#8217;m gonna explain how I&#8217;ve gotten to saying that, as you shouldn&#8217;t be making blind decisions about these things.  Most of the time when I implement caching for clients I completely skip page caching and action caching and go straight to line item caching, ie caching of small fragments of html.  Sounds completely counter-intuitive doesn&#8217;t it, but it&#8217;s not.</p>
<p style="text-align: justify;">First off I need to define a typical client&#8217;s website so you see where I&#8217;m coming from.  It&#8217;s a user driven web 2.0 website - so most of the data is user generated and sometimes social networking elements are included, where a user&#8217;s data can be restricted to just their friends instead of being publicly available.  Basically the site lists stuff that people put on it.</p>
<p style="text-align: justify;">Why not page or action caching?  As a starting point it&#8217;s too hard to manage due to the continually changing nature of the data being presented.  This changing nature means your cache might not actually get used that much.  Additionally when you are logged in your name is typically on the page with other unique to you info - you have x messages etc&#8230;  The latter reason completely rules out caching a whole page for anyone that&#8217;s logged in.  Don&#8217;t restrict caching based speed increases to joe public as logged in people, ie people that give a damn about your site, shouldn&#8217;t be second class citizens.</p>
<p style="text-align: justify;"><strong>Don&#8217;t start with caching lists</strong></p>
<p style="text-align: justify;">Developers still want to jump straight in and cache lists of items (and pages too) rather than the individual line items - basically as much of the page as they can in a single hit - thinking they&#8217;ll get great bang for their buck.  When you deploy with that strategy you&#8217;re in for a world of hurt.  This is because they&#8217;ve not realised they need to take the following into account.</p>
<p style="text-align: justify;">Each time one of the line items changes you have to expire the cache for the whole listing.  If you have pagination then you&#8217;ll likely have to expire ALL cached pages unless you can 100% reliably work out which page the item is on.  So yes you have a separate cache entry for each page of the listing.  If someone adds or edits a line item you have to expire the whole lot - and thats what people should be doing all the time on your site right?.  Additionally, if you allow sorting or a filtering mechanism you have to uniquely cache by page and the additional dimension(s), thus further reducing the frequency the cache will be used.</p>
<p style="text-align: justify;"><strong>What&#8217;s the goal?</strong></p>
<p style="text-align: justify;">What we are trying to achieve with caching is to DRY up the execution of requests, but in a way that doesn&#8217;t add complexity.  The idea is to let your servers focus on the unique stuff like processing credit cards and telling Jill&#8217;s friends that based on her network and comment history she really doesn&#8217;t like doing things with Sarah unless Joe is there too.</p>
<p style="text-align: justify;">Keep this in mind.  With seeking something to cache, you are basically looking for something that has a high ratio of renders/requests of the exact same html in between changes of that html.  So the more content in the cached fragment, the more frequently you&#8217;ll need to expire it.  Putting that another way, the fewer data sources, instances of models and display dimensions like pagination, sorting and filtering used to make up the cached html the better.  The simplest you can go is one data source, ie a line item.  Remember, keep it simple.</p>
<p style="text-align: justify;">Put in business speak, it&#8217;s a cost / benefit decision.</p>
<p style="text-align: justify;"><strong>It&#8217;s all about the keys</strong></p>
<p style="text-align: justify;">When you store fragments in your cache you name them with a unique string based key so you can access them later -  exactly like a hash.  So yes, they are important.  Typically they looks like a url, sort of based on the actual url or controller/action and the dimensions involved to make it unique to the html being cached.  So for the above listing situation the key should look something like this:</p>
<p style="text-align: justify;">&#8216;/products/list/sort=price/status=in-stock/page=1&#8242;</p>
<p style="text-align: justify;">This actually presents a completely separate reason as to why you shouldn&#8217;t do list caching when you start out on this path.  The problem with this key is that to expire it you have to count the number of products to determine how many pages there are and then manually go and expire all possible keys that could have been generated, one at a time - this is because expiring via regex is not supported.  If additional dimensions are involved the problem will compound even further.</p>
<p style="text-align: justify;">Yes, that&#8217;s real ugly and will become completely unmanageable.  There are some clever tricks to help out there such as self expiring keys, but that&#8217;s a different topic which I&#8217;ll get to at a later date.</p>
<p style="text-align: justify;"><strong>When to expire</strong></p>
<p style="text-align: justify;">Wait there&#8217;s more!  You have to monitor data changes so you can expire those keys when they become stale as it doesn&#8217;t happen magically.  Normally you&#8217;d setup a sweeper (observer) and just expire things when &#8216;after_save&#8217; is triggered.  Not a problem.  If you have data from multiple models involved in your cached html fragments then you need to monitor all the models involved.  You can go as far as only expiring particular keys based on the attributes that are changing etc&#8230; now much easier in Rails 2.1 with Dirty Objects.</p>
<p style="text-align: justify;">This is all adding yet another layer of complexity.  Ugh.  It should all be documented so that other developers know about it especially new developers - otherwise further work could mess it up and you might start showing stale data to users.  In my book that&#8217;s pretty much on par with errors occurring as you could be showing the wrong price or even deleted data to users.  Unless you are careful about it, it can all become some really hard to manage mess which really isn&#8217;t going to give much benefit to your users.</p>
<p style="text-align: justify;"><strong>Line item caching</strong></p>
<p style="text-align: justify;">As you are not having to worry about other dimensions such as pagination, sort order and filtering, other line items or even if the user is logged in or not, the line item&#8217;s cache key should be something like this:</p>
<p style="text-align: justify;">&#8216;/products/#{product.id}/line_item&#8217;</p>
<p style="text-align: justify;">To make sure it expires correctly all you have to do is setup a sweeper watching the line item and simply delete it&#8217;s key when it changes - use Rails.cache.delete for this.  If the line item is rendered using data from through relationships, you then have to monitor them too.  I&#8217;ve seen people putting a &#8216;last_active_at&#8217; field on a line item and when anything related to it changes they update that time field.  That works nicely and things are kept simple.</p>
<p style="text-align: justify;"><strong>Finally</strong></p>
<p style="text-align: justify;">That should set you off in the right direction, remembering though this is a starting point for your first caching strategy.  Later on you&#8217;ll actually start doing multiple layers of caching and covering more complex html, such as lists, if your site continues to grow.</p>
<p style="text-align: justify;">Now hopefully I&#8217;ve convinced you to start out with caching the html for a single line item - or something just as simple.  If not post a comment and tell me why not.</p>


<p>Related posts:<ol><li><a href='http://www.motionstandingstill.com/spandex-memcache-store-is-now-in-rails-23/2009-02-04/' rel='bookmark' title='Permanent Link: Spandex Memcache Store is now in Rails 2.3'>Spandex Memcache Store is now in Rails 2.3</a> <small>Just a quick note to say that the local cache...</small></li><li><a href='http://www.motionstandingstill.com/be-careful-how-you-count/2008-09-12/' rel='bookmark' title='Permanent Link: Be careful how you count in Rails'>Be careful how you count in Rails</a> <small>I&#8217;ve just encountered this problem yet again effecting code I&#8217;m...</small></li><li><a href='http://www.motionstandingstill.com/i-dont-use-foreign-key-constraints-with-rails/2008-10-17/' rel='bookmark' title='Permanent Link: I don&#8217;t use Foreign Key Constraints with Rails'>I don&#8217;t use Foreign Key Constraints with Rails</a> <small>A couple of months back we had Nigel talking at...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/motionstandingstill/~4/2_JlCz93-yU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/starting-simple-with-rails-caching/2008-11-27/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.motionstandingstill.com/starting-simple-with-rails-caching/2008-11-27/</feedburner:origLink></item>
		<item>
		<title>How to reduce your memcache reads</title>
		<link>http://feedproxy.google.com/~r/motionstandingstill/~3/whlIwCoY4k8/</link>
		<comments>http://www.motionstandingstill.com/how-to-reduce-your-memcache-reads/2008-11-14/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 00:21:23 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
		
		<category><![CDATA[Memcache]]></category>

		<category><![CDATA[spandex mem cache store]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=184</guid>
		<description><![CDATA[Several months back I presented at WellRailed on using Memcache with Rails.  I focused on fragment caching and the libraries I&#8217;d created to make life easier.  I&#8217;ve now moved some of what I discussed into a plugin available at github which I&#8217;ve described as follows:
A enhanced version of and replacement for the MemCacheStore shipping with [...]


Related posts:<ol><li><a href='http://www.motionstandingstill.com/spandex-memcache-store-is-now-in-rails-23/2009-02-04/' rel='bookmark' title='Permanent Link: Spandex Memcache Store is now in Rails 2.3'>Spandex Memcache Store is now in Rails 2.3</a> <small>Just a quick note to say that the local cache...</small></li><li><a href='http://www.motionstandingstill.com/spandex-mem-cache-store/' rel='bookmark' title='Permanent Link: Spandex Mem Cache Store'>Spandex Mem Cache Store</a> <small>taken from the plugin&#8217;s README Description A enhanced version of...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Several months back I presented at <a href="http://groups.google.com/group/WellRailed" target="_blank">WellRailed</a> on using Memcache with Rails.  I focused on fragment caching and the libraries I&#8217;d created to make life easier.  I&#8217;ve now moved some of what I discussed into a <a href="http://github.com/terrcin/spandex_mem_cache_store/tree/master" target="_blank">plugin available at github</a> which I&#8217;ve described as follows:</p>
<blockquote style="text-align: justify;"><p>A enhanced version of and replacement for the MemCacheStore shipping with rails.  It uses a per-request local cache to buffer duplicate memcache reads which can result in halving read requests, and it uses a single connection to memcache for both the cache and session stores.</p></blockquote>
<p style="text-align: justify;">It doesn&#8217;t yet have the awesome key creation and maintenance library that I showed as that has evolved quite a bit and needs a big bunch of love first - which I&#8217;m working on.</p>
<p style="text-align: justify;">There is now a <a href="http://www.motionstandingstill.com/spandex-mem-cache-store/" target="_blank">dedicated page</a> on this site for the plugin, currently it&#8217;s holds a copy of the plugin&#8217;s README.  My intention is to update the page with examples etc.. as I extend the plugin.</p>


<p>Related posts:<ol><li><a href='http://www.motionstandingstill.com/spandex-memcache-store-is-now-in-rails-23/2009-02-04/' rel='bookmark' title='Permanent Link: Spandex Memcache Store is now in Rails 2.3'>Spandex Memcache Store is now in Rails 2.3</a> <small>Just a quick note to say that the local cache...</small></li><li><a href='http://www.motionstandingstill.com/spandex-mem-cache-store/' rel='bookmark' title='Permanent Link: Spandex Mem Cache Store'>Spandex Mem Cache Store</a> <small>taken from the plugin&#8217;s README Description A enhanced version of...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/motionstandingstill/~4/whlIwCoY4k8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/how-to-reduce-your-memcache-reads/2008-11-14/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.motionstandingstill.com/how-to-reduce-your-memcache-reads/2008-11-14/</feedburner:origLink></item>
		<item>
		<title>Attributes not saving for models with attachments</title>
		<link>http://feedproxy.google.com/~r/motionstandingstill/~3/IAP9waY-Kmo/</link>
		<comments>http://www.motionstandingstill.com/attributes-not-saving-for-models-with-attachments/2008-11-05/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 21:53:54 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
		
		<category><![CDATA[Miscellaneous]]></category>

		<category><![CDATA[attachment_fu]]></category>

		<category><![CDATA[attr_accessible]]></category>

		<category><![CDATA[attr_protected]]></category>

		<category><![CDATA[blacklist]]></category>

		<category><![CDATA[mass-assign]]></category>

		<category><![CDATA[whitelist]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=170</guid>
		<description><![CDATA[I was upgrading a client&#8217;s application to Rails 2.1.2 from 2.0.x the other day, this resulted in refreshing a number of gems and plugins including will_paginate and attachment_fu.  In doing so I found a stupid problem that I couldn&#8217;t find anything about online - it&#8217;s a pretty one off unique case so I thought I&#8217;d [...]


Related posts:<ol><li><a href='http://www.motionstandingstill.com/ngnix-upload-awesomeness-pt2/2008-08-20/' rel='bookmark' title='Permanent Link: Ngnix Upload Awesomeness pt2'>Ngnix Upload Awesomeness pt2</a> <small>Eek, a week&#8217;s gone by without a blog entry.  The...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I was upgrading a client&#8217;s application to Rails 2.1.2 from 2.0.x the other day, this resulted in refreshing a number of gems and plugins including <a href="http://github.com/mislav/will_paginate/tree/master" target="_blank">will_paginate</a> and <a href="http://github.com/technoweenie/attachment_fu/tree/master" target="_blank">attachment_fu</a>.  In doing so I found a stupid problem that I couldn&#8217;t find anything about online - it&#8217;s a pretty one off unique case so I thought I&#8217;d blog about it to help the next person.  &#8216;Pay it forward&#8217; I guess.</p>
<p style="text-align: justify;">The problem was this: somewhere along the line attachment_fu was updated to execute the following line of code on classes using the <em>has_attachment</em> directive:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">attr_accessible <span style="color:#ff3333; font-weight:bold;">:uploaded_data</span></pre></div></div>

<p style="text-align: justify;">This is taking advantage of a security feature in Rails, it instructs the model to only allow :uploaded_data to be set through <em>update_attributes</em> and any like methods such as <em>new</em> and <em>create</em>.  So <a href="http://en.wikipedia.org/wiki/Whitelist" target="_blank">whitelisting</a> bulk settable attributes.  It doesn&#8217;t raise any errors, just warnings in your log like this:</p>

<div class="wp_syntax"><div class="code"><pre class="log" style="font-family:monospace;">WARNING: Can't mass-assign these protected attributes: &lt;attribute_name&gt;</pre></div></div>

<p style="text-align: justify;">Due to no errors being raised the problem was presenting itself in other parts of the application as expected data was not being found.  Fortunately I was tailing my dev log and noticed the above warning message.</p>
<p style="text-align: justify;">The problem in this situation was the historic code creating instances of the model by passing a hash through to <em>SomeModel.create</em>.  As this area of code was not utilising data posted to an action it was not a security risk.  Very fustrating, especially as this was common practice throughout the codebase.</p>
<p style="text-align: justify;">As I didn&#8217;t want to do a huge bunch of re-keying my initial solution was to comment out the offending line in attachment_fu.  Yes this is a big nasty fix but there was time pressure, other problems to solve and I didn&#8217;t want to be held up having caused an unnecessary amount of manual testing.  In case it was forgotten about  and overriden with a future plugin update, a quick test with big comment was added.</p>
<p style="text-align: justify;">This project hadn&#8217;t updated it&#8217;s gems and plugins for a while, meaning it was a big shock to the system when they where.  This was the biggest headache, all other problems were mainly just gem interfaces changing, so a easy search and replace matter.</p>
<p style="text-align: justify;">I like passing a hash to mass-assign data in Rails as well as the obvious coding benefits it&#8217;s visually more readable too, but this is out weighed by my great dislike of having my sites hacked into.  So it&#8217;s a shame things have had to go this way.</p>


<p>Related posts:<ol><li><a href='http://www.motionstandingstill.com/ngnix-upload-awesomeness-pt2/2008-08-20/' rel='bookmark' title='Permanent Link: Ngnix Upload Awesomeness pt2'>Ngnix Upload Awesomeness pt2</a> <small>Eek, a week&#8217;s gone by without a blog entry.  The...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/motionstandingstill/~4/IAP9waY-Kmo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/attributes-not-saving-for-models-with-attachments/2008-11-05/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.motionstandingstill.com/attributes-not-saving-for-models-with-attachments/2008-11-05/</feedburner:origLink></item>
		<item>
		<title>Wordpress with Nginx on Slicehost</title>
		<link>http://feedproxy.google.com/~r/motionstandingstill/~3/xQ3qkRTn2zg/</link>
		<comments>http://www.motionstandingstill.com/wordpress-with-nginx-on-slicehost/2008-10-23/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 22:28:32 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
		
		<category><![CDATA[Miscellaneous]]></category>

		<category><![CDATA[nginx]]></category>

		<category><![CDATA[slicehost]]></category>

		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=162</guid>
		<description><![CDATA[Over the weekend I moved this blog from being hosted on my Dreamhost account to one of my 256mb Slicehost servers.
I&#8217;ve done this mainly to stop paying for hosting twice, but also because if I&#8217;m going to be talking about performance I can&#8217;t possibly have a slow blog and my options were limited with the [...]


Related posts:<ol><li><a href='http://www.motionstandingstill.com/nginx-upload-awesomeness/2008-08-13/' rel='bookmark' title='Permanent Link: Nginx upload awesomeness'>Nginx upload awesomeness</a> <small>I&#8217;ve been a bit busy earning my keep for the...</small></li><li><a href='http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/' rel='bookmark' title='Permanent Link: Using Nginx to send files with x-accel-redirect'>Using Nginx to send files with x-accel-redirect</a> <small>So far I&#8217;ve configured Nginx to handle file uploads by...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Over the weekend I moved this blog from being hosted on my <a href="http://www.dreamhost.com" target="_blank">Dreamhost</a> account to one of my 256mb <a href="http://www.slicehost.com" target="_blank">Slicehost</a> servers.</p>
<p style="text-align: justify;">I&#8217;ve done this mainly to stop paying for hosting twice, but also because if I&#8217;m going to be talking about performance I can&#8217;t possibly have a slow blog and my options were limited with the Dreamhost account.</p>
<p style="text-align: justify;">My immediate problem being that I wanted to move it straight to being served by Ngnix rather than Apache - not something that Wordpress is setup for.  After a bit of googling I found that someone had solved all the problems I was going to have for me!  This <a href="http://www.mensk.com/webmaster-toolbox/perfect-ubuntu-hardy-nginx-mysql5-php5-wordpress/" target="_blank">post</a> has blow by blow instructions for setting up a wordpress blog on Slicehost and Ubuntu, I couldn&#8217;t have found anything better.</p>
<p style="text-align: justify;">It worked exactly as advertised, but me being me I could help tweaking and updated the nginx site config to include expire header for static assets, like so:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">server
  <span style="color: #7a0874; font-weight: bold;">&#123;</span>
&nbsp;
  listen   <span style="color: #000000;">80</span>;
  server_name www.motionstandingstill.com;
&nbsp;
  root   <span style="color: #000000; font-weight: bold;">&lt;</span>path_to_site<span style="color: #000000; font-weight: bold;">&gt;</span>;
&nbsp;
  access_log <span style="color: #000000; font-weight: bold;">&lt;</span>custom_log_path<span style="color: #000000; font-weight: bold;">&gt;/</span>access.log;
  error_log <span style="color: #000000; font-weight: bold;">&lt;</span>custom_log_path<span style="color: #000000; font-weight: bold;">&gt;/</span>error.log;
&nbsp;
  location ~<span style="color: #000000; font-weight: bold;">*</span> i.+\.<span style="color: #7a0874; font-weight: bold;">&#40;</span>css<span style="color: #000000; font-weight: bold;">|</span>js<span style="color: #000000; font-weight: bold;">|</span>jpg<span style="color: #000000; font-weight: bold;">|</span>jpeg<span style="color: #000000; font-weight: bold;">|</span>gif<span style="color: #000000; font-weight: bold;">|</span>png<span style="color: #7a0874; font-weight: bold;">&#41;</span>$
    <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    expires      7d;
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
  location <span style="color: #000000; font-weight: bold;">/</span>
    <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    index  index.php index.html;
&nbsp;
    <span style="color: #666666; font-style: italic;"># Basic version of Wordpress parameters, supporting nice permalinks.</span>
    <span style="color: #666666; font-style: italic;"># include /etc/nginx/conf/wordpress_params.regular;</span>
    <span style="color: #666666; font-style: italic;"># Advanced version of Wordpress parameters supporting nice permalinks and WP Super Cache plugin</span>
    include <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>wordpress_params.super_cache;
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000</span>
  location ~ \.php$
    <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    fastcgi_pass 127.0.0.1:<span style="color: #000000;">9000</span>;
    fastcgi_index index.php;
    include <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>fastcgi_params;
    fastcgi_param SCRIPT_FILENAME <span style="color: #000000; font-weight: bold;">&lt;</span>site_path<span style="color: #000000; font-weight: bold;">&gt;/</span>public<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$fastcgi_script_name</span>;
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #666666; font-style: italic;"># server</span></pre></div></div>

<p style="text-align: justify;">Later I found someone had posted a <a href="http://wpmu.org/nginx-wordpress-26/" target="_blank">different conf</a> with easy support for multiple blogs, but I&#8217;ve not moved to using it as what I&#8217;ve got works.  What it also does is add the expire clause support like I have done above.</p>
<p style="text-align: justify;">When moving this blog to Slicehost I initially set it up on a temp subdomain to make sure it was working sweet first and because I wanted to try out some different themes and play with a couple of other things.</p>
<p style="text-align: justify;">I quickly discovered that as it was running on a different doman than it was configured for, Wordpress would redirect my browser to the correct domain meaning I couldn&#8217;t get into the new site.  Ugh.  So I had to whip out my sql skills and manually update the appropriate settings.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> wp_options <span style="color: #993333; font-weight: bold;">SET</span> option_value <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'http://temp.motionstandingstill.com'</span> <span style="color: #993333; font-weight: bold;">WHERE</span> option_value <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'http://www.motionstandingstill.com'</span>;</pre></div></div>

<p style="text-align: justify;">I actually used a different domain name and explicitly updated two rows rather than the generic &#8216;where&#8217; clause I have, but you get the idea.  This allowed me in which is what I wanted.</p>
<p style="text-align: justify;">Then I took the opportunity to tidy up what plugins I&#8217;m using as I&#8217;d gotten a bit &#8216;plugin install happy&#8217; when first setting the blog up.  As well as getting rid of unwanted plugins I installed two new plugins I&#8217;d recently found, the first a <a href="http://urbangiraffe.com/plugins/redirection/" target="_blank">redirection plugin with regex support</a> and the second a <a href="http://wordpress.org/extend/plugins/wp-security-scan/" target="_blank">security checking</a> plugin.</p>
<p style="text-align: justify;">Once I&#8217;d got everything how I wanted it, just sticking with the same theme (the misty tree photo is mine), I grabbed a final db backup from Dreamhost and restored it on Slicehost then changed my DNS A record.</p>
<p style="text-align: justify;">All in all, much easier than I thought it would going to be thanks to some helpful results from google. :-)</p>
<p style="text-align: justify;">
<strong>Update</strong>: Slicehost has been <a href="http://www.slicehost.com/blog/" target="_blank">aquired</a> by <a href="http://www.rackspace.com/index.php" target="_blank">Rackspace</a>.</p>


<p>Related posts:<ol><li><a href='http://www.motionstandingstill.com/nginx-upload-awesomeness/2008-08-13/' rel='bookmark' title='Permanent Link: Nginx upload awesomeness'>Nginx upload awesomeness</a> <small>I&#8217;ve been a bit busy earning my keep for the...</small></li><li><a href='http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/' rel='bookmark' title='Permanent Link: Using Nginx to send files with x-accel-redirect'>Using Nginx to send files with x-accel-redirect</a> <small>So far I&#8217;ve configured Nginx to handle file uploads by...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/motionstandingstill/~4/xQ3qkRTn2zg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/wordpress-with-nginx-on-slicehost/2008-10-23/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.motionstandingstill.com/wordpress-with-nginx-on-slicehost/2008-10-23/</feedburner:origLink></item>
		<item>
		<title>I don’t use Foreign Key Constraints with Rails</title>
		<link>http://feedproxy.google.com/~r/motionstandingstill/~3/mfbdjo_9PBs/</link>
		<comments>http://www.motionstandingstill.com/i-dont-use-foreign-key-constraints-with-rails/2008-10-17/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 23:45:58 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
		
		<category><![CDATA[Features]]></category>

		<category><![CDATA[Miscellaneous]]></category>

		<category><![CDATA[convention over configuration]]></category>

		<category><![CDATA[documentation]]></category>

		<category><![CDATA[dry]]></category>

		<category><![CDATA[foreign key constraints]]></category>

		<category><![CDATA[mvc]]></category>

		<category><![CDATA[pragmatism]]></category>

		<category><![CDATA[premature optmisation]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=152</guid>
		<description><![CDATA[A couple of months back we had Nigel talking at WellRailed about a Foreign Key Constraint plugin he uses with Rails and then just this week the topic was brought up again for me with a client.  I&#8217;ve found it&#8217;s something that pops up every now and again.  Given this is such a polarizing issue [...]


Related posts:<ol><li><a href='http://www.motionstandingstill.com/starting-simple-with-rails-caching/2008-11-27/' rel='bookmark' title='Permanent Link: Starting simple with Rails caching'>Starting simple with Rails caching</a> <small>So, you’ve launched your website and increasingly people are actually...</small></li><li><a href='http://www.motionstandingstill.com/be-careful-how-you-count/2008-09-12/' rel='bookmark' title='Permanent Link: Be careful how you count in Rails'>Be careful how you count in Rails</a> <small>I&#8217;ve just encountered this problem yet again effecting code I&#8217;m...</small></li><li><a href='http://www.motionstandingstill.com/spandex-memcache-store-is-now-in-rails-23/2009-02-04/' rel='bookmark' title='Permanent Link: Spandex Memcache Store is now in Rails 2.3'>Spandex Memcache Store is now in Rails 2.3</a> <small>Just a quick note to say that the local cache...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">A couple of months back we had <a href="http://workingwithrails.com/person/9576-nigel-ramsay" target="_blank">Nigel</a> talking at <a href="http://groups.google.com/group/WellRailed" target="_blank">WellRailed</a> about a Foreign Key Constraint plugin he uses with Rails and then just this week the topic was brought up again for me with a client.  I&#8217;ve found it&#8217;s something that pops up every now and again.  Given this is such a polarizing issue I thought I&#8217;d order my thoughts into a post explaining why I don&#8217;t use foreign key constraints, in particular cascading deletes.</p>
<p style="text-align: justify;">For me the reasoning is distilled down to my programming style.</p>
<p style="text-align: justify;"><strong>Pragmatism</strong></p>
<p style="text-align: justify;">When it comes down to it, what vital benefit does it give you over :dependent =&gt; :destroy or model validation?  Will this give you increased quality faster, quicker and cheaper?</p>
<p style="text-align: justify;"><strong>Premature Optmisation</strong></p>
<p style="text-align: justify;">Basically don&#8217;t waste time optimising something that isn&#8217;t slow or is hardly used.  Rails is so slow that some fractional speedup on the DB isn&#8217;t really going to be noticeable by the end user.  Instead examine your site with <a href="http://www.newrelic.com/" target="_blank">NewRelic</a> or <a href="http://www.fiveruns.com/" target="_blank">FiveRuns</a> and fix your bottleneck code - way more bang for your buck.</p>
<p style="text-align: justify;"><strong>Data is Valuable</strong></p>
<p style="text-align: justify;">So don&#8217;t go around deleting it!  If a user wants to delete some data you should want to know why.  Looking at the data can aid in determining why without having to bug the user about it.  Yes there are occasions when this does need to happen, but they should be the exception to the rule and thus explicitly coded for.</p>
<p style="text-align: justify;">Just mark a record as deleted and filter it out automatically, that&#8217;s easy enough to do with rails - way easier than any other language I&#8217;ve used before.  Better yet, search <a href="http://www.github.com" target="_blank">github</a> and use someone else&#8217;s wheel.</p>
<p style="text-align: justify;"><strong>Convention Over Configuration</strong></p>
<p style="text-align: justify;">Basically put, you do things the way that everyone else has done it.  Walk the well walked path so to speak&#8217; and you won&#8217;t experience any bizzaro problems that someone else hasn&#8217;t already solved before you.  As you&#8217;ve created your app in a predictable way, someone else can easily come in and contribute to your project, or visa-versa and it makes the whole Rails community more accessible to you.</p>
<p style="text-align: justify;">So in following the conventions and as you are not encouraged to use foreign key constraints, Rails isn&#8217;t expecting data to be deleted out from underneath it.</p>
<p style="text-align: justify;"><strong>Don&#8217;t Repeat Yourself &amp;&amp; Model View Controller</strong></p>
<p style="text-align: justify;"><a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself" target="_blank">DRY</a> is another of the core philosophies behind Rails - partials are a real good example of this especially when you start to think of them as essentially methods.  On top of the obvious &#8217;speed to deliver&#8217; benefits this concept provides, it also causes you to distill your code down to being more readable and accessible.  This ties in nicely with <a href="http://en.wikipedia.org/wiki/Model-view-controller" target="_blank">MVC</a> principles as you then tend to group like logic together which is what MVC is all about.</p>
<p style="text-align: justify;">Foreign key constraints are business logic as they describe and implement a behavior - &#8220;when you delete this record, also delete these other records over here&#8221;.  So why would you go and put some &#8216;important to know about&#8217; business logic in an isolated and often hard to reach place?</p>
<p style="text-align: justify;"><strong>Documentation</strong></p>
<p style="text-align: justify;">The one great thing I learned from <a href="http://www.stevemcconnell.com/" target="_blank">Steve McConnell&#8217;s</a> <a href="http://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1224199994&amp;sr=1-1" target="_blank">Code Complete</a> was how to write comments, they should describe the intention of the code, rather then repeat the code.  This nicely ties in with the DRY principle.</p>
<p style="text-align: justify;">I&#8217;m also a great believer in self documenting code, Rails and Ruby help heaps with this, and generally write comments to help simplify complex code.  Instead of my code being littered with redundant comments cluttering everything up, it just contains important ones as they are more likely to be read and updated when the code is next worked on.</p>
<p style="text-align: justify;">If you use foreign key constraints in your DB you&#8217;ll likely end up documenting them (ie repeating them) somewhere more accessible, in the models being an obvious place.  That wouldn&#8217;t be because the business logic lives there would it?.  Have a think about that.</p>
<p style="text-align: justify;"><strong>The Rails Way</strong></p>
<p style="text-align: justify;">Looking at the Convention over configuration, Don&#8217;t Repeat Yourself and Model View Controller concepts above - as much as Rails is a framework it&#8217;s also about a way of doing things.</p>
<p style="text-align: justify;">Over the years I&#8217;ve seen a notable number of people, new to rails and these concepts, trying to make rails work their way - often with less than desirable results.  If you embrace Rails and it&#8217;s &#8216;way&#8217; then it works beautifully and is a pure joy to use, rather than a frustrating experience.</p>
<p style="text-align: justify;"><strong>For me</strong></p>
<p style="text-align: justify;">Coding is an art form and as such a creative process.  If something doesn&#8217;t look, or even feel right then it&#8217;s wrong.  In the end foreign key constraints on a web app just rub me up the wrong way.</p>


<p>Related posts:<ol><li><a href='http://www.motionstandingstill.com/starting-simple-with-rails-caching/2008-11-27/' rel='bookmark' title='Permanent Link: Starting simple with Rails caching'>Starting simple with Rails caching</a> <small>So, you’ve launched your website and increasingly people are actually...</small></li><li><a href='http://www.motionstandingstill.com/be-careful-how-you-count/2008-09-12/' rel='bookmark' title='Permanent Link: Be careful how you count in Rails'>Be careful how you count in Rails</a> <small>I&#8217;ve just encountered this problem yet again effecting code I&#8217;m...</small></li><li><a href='http://www.motionstandingstill.com/spandex-memcache-store-is-now-in-rails-23/2009-02-04/' rel='bookmark' title='Permanent Link: Spandex Memcache Store is now in Rails 2.3'>Spandex Memcache Store is now in Rails 2.3</a> <small>Just a quick note to say that the local cache...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/motionstandingstill/~4/mfbdjo_9PBs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/i-dont-use-foreign-key-constraints-with-rails/2008-10-17/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.motionstandingstill.com/i-dont-use-foreign-key-constraints-with-rails/2008-10-17/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 2.279 seconds --><!-- Cached page served by WP-Cache -->
