<?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>Arie's Blog &#187; Programming</title>
	<atom:link href="http://ariekanarie.nl/category/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://ariekanarie.nl</link>
	<description></description>
	<lastBuildDate>Mon, 14 Jun 2010 09:48:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Rails on OS X: no such file to load &#8212; mysql</title>
		<link>http://ariekanarie.nl/archives/128/rails-on-os-x-no-such-file-to-load-mysql</link>
		<comments>http://ariekanarie.nl/archives/128/rails-on-os-x-no-such-file-to-load-mysql#comments</comments>
		<pubDate>Wed, 11 Mar 2009 11:24:55 +0000</pubDate>
		<dc:creator>Arie</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://ariekanarie.nl/?p=128</guid>
		<description><![CDATA[Just a quick post to maybe help someone who has a similar problem: I had the following error whenever I tried to use &#8216;script/console&#8217; (script/server and rake worked fine) require &#8216;mysql&#8217; MissingSourceFile: no such file to load &#8212; mysql from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require&#8217; from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require&#8217; Turns out I had multiple versions of RubyGems installed on [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick post to maybe help someone who has a similar problem:</p>
<p>I had the following error whenever I tried to use &#8216;script/console&#8217; (script/server and rake worked fine)</p>
<blockquote><p>require &#8216;mysql&#8217;</p>
<p>MissingSourceFile: no such file to load &#8212; mysql<br />
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require&#8217;<br />
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require&#8217;</p></blockquote>
<p>Turns out I had multiple versions of RubyGems installed on my Macbook. The error message already spoils it by saying rubygems in /System/Library/Framework/ is being called, while I actually installed rubygems manually in a different folder.</p>
<p>To prevent these kind of problems in the future I simply deleted the entire Ruby.framework directory and use the manually installed versions instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://ariekanarie.nl/archives/128/rails-on-os-x-no-such-file-to-load-mysql/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Switching from Ubuntu/Windows to Mac OS X</title>
		<link>http://ariekanarie.nl/archives/107/switching-from-ubuntuwindows-to-mac-os-x</link>
		<comments>http://ariekanarie.nl/archives/107/switching-from-ubuntuwindows-to-mac-os-x#comments</comments>
		<pubDate>Wed, 21 Jan 2009 22:11:26 +0000</pubDate>
		<dc:creator>Arie</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://ariekanarie.nl/?p=107</guid>
		<description><![CDATA[I&#8217;ve been using my new Macbook for a whopping two days now, so I think it&#8217;s time to share some of my early impressions. First of all, I&#8217;m not a typical computer user. I&#8217;m picky, opinionated and totally unreasonable when it comes to my requirements for an Operating System. Before my Macbook my setup consisted [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-117   alignright" style="border: 0pt none;" title="apple-logo" src="http://ariekanarie.nl/wordpress/wp-content/uploads/2009/01/apple-logo.png" alt="apple-logo" width="152" height="186" /></p>
<p>I&#8217;ve been using my new Macbook for a whopping two days now, so I think it&#8217;s time to share some of my early impressions.</p>
<p>First of all, I&#8217;m not a typical computer user. I&#8217;m picky, opinionated and totally unreasonable when it comes to my requirements for an Operating System. Before my Macbook my setup consisted of:</p>
<ul>
<li>Desktop PC, Windows XP: Used for gaming mainly, also editting photo&#8217;s and as a &#8216;<a href="http://en.wikipedia.org/wiki/Thin_client" target="_blank">fat client</a>&#8216; for Putty</li>
<li>Laptop, Ubuntu: Used for work and midnight-coding. Purely a development tool for developing Ruby on Rails webapplications, accessing <a href="http://icanhascheezburger.com/" target="_blank">icanhazcheeseburger.com</a> and <a href="http://punditkitchen.com/" target="_blank">other</a> <a href="http://graphjam.com/" target="_blank">important</a> <a href="http://www.dilbert.com/" target="_blank">work</a> <a href="http://thedailywtf.com/">stuff</a>.</li>
</ul>
<p><span id="more-107"></span></p>
<p>The Windows XP of my desktop PC is a necessary evil. Games for Linux and Mac OS X are rare and my girlfriend still has an emergency Windows-account she can use whenever her Windows XP laptop refuses to work properly. Simply put: I&#8217;m stuck with XP for my desktop and I don&#8217;t really mind (a lot).</p>
<p><img class="alignnone size-medium wp-image-116" style="border: 0pt none;" title="607px-ubuntu_logosvg" src="http://ariekanarie.nl/wordpress/wp-content/uploads/2009/01/607px-ubuntu_logosvg-300x78.png" alt="607px-ubuntu_logosvg" width="300" height="78" /></p>
<p>The laptop running <a href="http://http://www.ubuntu.com/" target="_blank">Ubuntu</a> belongs to <a href="http://www.finalist.com/" target="_blank">my employer</a>. Ubuntu is an excellent platform to develop <a href="http://rubyonrails.org/" target="_blank">Ruby on Rails</a> applications, the <a href="http://packages.ubuntu.com/intrepid/" target="_blank">huge Ubuntu repository </a>contains recent version of all necessary tools and the <a href="http://en.wikipedia.org/wiki/Advanced_Packaging_Tool" target="_blank">apt package manager</a> is simply unmatched on any platform. To isolate myself from outside influences during coding sessions I use a closed headphone and <a href="http://amarok.kde.org/" target="_blank">Amarok</a> (a rather bloated <a href="http://kde.org/" target="_blank">KDE</a> program, so I can&#8217;t bitch about iTunes without being an ever bigger hypocrit). <a href="http://pidgin.im" target="_blank">Pidgin</a> provides me with access to nearly all IM networks, while <a href="https://addons.mozilla.org/en-US/firefox/addon/5081" target="_blank">TwitterFox</a> keeps me in touch with fellow twitterati.</p>
<p>My new Macbook is supposed to replace the Ubuntu laptop and serve as an alternative to my desktop at home. Here are some of my initial thoughts regarding this migration:</p>
<blockquote><p><em><strong>It just works</strong></em></p></blockquote>
<p>It doesn&#8217;t.</p>
<p>Ok to be fair, a lot of stuff just &#8216;works&#8217;, I am however spoilt by Ubuntu 8.10 which also &#8216;just works&#8217;, it just fails to work on different points compared to Mac OS X. OS X fails to &#8216;just work&#8217; as a Ruby on Rails development environment, sure it comes preloaded with Ruby on Rails, but it has ancient version of Rails, Ruby and Rake and this completely screwed me over while trying to convert my fresh Macbook into the ultimate web-development machine.</p>
<p>Multimedia support is not as good out of the box as Ubuntu. In Ubuntu all the codecs you need are in the repository and are a easy to install. To be fair, this is only since the 8.x branch of Ubuntu. For OS X I had to find a bunch of codecs from questionable vendors (I&#8217;ll never trust the DivX corporation after their bloated Windows installers) before I could get my movies and series to play in Quicktime.<br />
Speaking of horrible failures, I don&#8217;t see how anyone could enjoy Quicktime. It&#8217;s completely inadequate compared to Zoom Player on Windows or MPlayer on Linux. I&#8217;m planning to replace it by something decent ASAP. Preferbly something pretty like <a href="http://http://xbmc.org/" target="_blank">XBMC</a> or the OS X specific port of this brilliant project.</p>
<blockquote><p><em><strong>Package management? What&#8217;s that?</strong></em></p></blockquote>
<p>Mac OS X understands package management just like <a href="http://www.youtube.com/watch?v=_GxC4kKD9qA" target="_blank">this girl</a> understands &#8220;PC&#8217;s&#8221;. Not a clue. Everything application you install has it&#8217;s own auto-update function and the built-in Software Update is about as useful as &#8220;Microsoft Update&#8221;. Which is not bad, it&#8217;s just not as great as Ubuntu&#8217;s software updater.</p>
<blockquote><p><em><strong>MacPorts &lt; apt</strong></em></p></blockquote>
<p><a href="http://www.macports.org/" target="_blank">MacPorts</a> is similar to Debian/Ubuntu&#8217;s APT. It provides an easy way to install and update software for your Mac. Unfortunately it&#8217;s more like Gentoo&#8217;s &#8216;<a href="http://en.wikipedia.org/wiki/Portage_(software)#emerge" target="_blank">emerge</a>&#8216; and less like Debian&#8217;s &#8216;apt-get&#8217;. Everything you install has to be compiled first, and if you want to install something with fancy graphics you&#8217;ll have to wait for an hour while the X window manager gets compiled (ok, this is only the first time).<br />
Fortunately it does what it&#8217;s supposed to, it just takes quite a lot longer than APT and the repository of available software is tiny compared to Ubuntu&#8217;s insane heap of <a href="http://en.wikipedia.org/wiki/Free_and_Open_Source_Software" target="_blank">FOSS</a>. For example, something like &#8216;<a href="http://htop.sourceforge.net/">htop</a>&#8216; is not available on OS X, but luckily there&#8217;s the <a href="http://guides.macrumors.com/Activity_Monitor" target="_blank">Activity Monitor</a> GUI to offer some compensation.</p>
<blockquote><p><em><strong>OS X &lt; GNU</strong></em></p></blockquote>
<p>Mac OS X implements all the usual Unix tools. Things like find and grep. These are kinda different to the GNU-tools I used on my Ubuntu laptop and Debian servers. As far as I can tell after these few days of use, the Mac OS X versions are inferior to their GNU-siblings. I&#8217;ll have to get used to this or find alternative tools</p>
<p>So much for the bitching, here are a few things I do like:</p>
<blockquote><p><em><strong>It just works</strong></em></p></blockquote>
<p>A lot of stuff works just fine out of the box. The prepackaged software gives Ubuntu a good run for it&#8217;s money. Also, it&#8217;s obvious OS X is more popular than Linux. Quite a few software products offer a reasonable up-to-date version for Mac. Skype for example has a Mac version which is nearly identical to the Windows version, while the Linux version is lacking a lot.</p>
<blockquote><p><em><strong>Basic hardware compatibility is not an issue</strong></em></p></blockquote>
<p>If you&#8217;re the only one making hardware for your OS (or is it the other way around?) it&#8217;s easy to make that hardware supported in the OS. While the linux kernel provides support for nearly every graphics card, sound card, IDE controller and toaster made in the history of electronics, OS X only has to support the very limited set of hardware used by Apple. And to Apple&#8217;s credit, it does this very well. Unlike Linux they don&#8217;t have to work around crappy vendors breaking standards that crash your laptop after a resume-from-standby. As a result, stuff like suspend-to-ram and connecting multiple monitors works really well and quickly.</p>
<blockquote><p><em><strong>It&#8217;s a lot like Linux</strong></em></p></blockquote>
<p>Overall I feel quite at home in OS X already. I was able to set up a proper development environment during a single evening, inspite of the great efforts of MacPorts to keep compiling very large bits of software. During the coming weeks I expect to find a lot more things that are different/worse/better in OS X compared to Ubuntu but the past few days have made me optimistic about the chances of OS X being the only OS on this Macbook. I originally intended to go for a triple boot setup; Windows XP, Ubuntu and OS X, but I think I&#8217;ll settle for installing Windows XP in a VirtualBox. Not because I like XP that much, but for testing web-application in the <a href="http://en.wikipedia.org/wiki/Internet_Explorer_6" target="_blank">worst browser ever made</a> and it&#8217;s younger brothers.</p>
<p>That&#8217;s it for now, I&#8217;ll probably write a new post in a couple of weeks, because I&#8217;m sure OS X has plenty of annoyances and amazements left in store for me.<img class="alignright size-thumbnail wp-image-115" style="border: 0pt none;" title="internet_explorer_logo_old" src="http://ariekanarie.nl/wordpress/wp-content/uploads/2009/01/internet_explorer_logo_old-150x150.png" alt="internet_explorer_logo_old" width="150" height="150" /></p>
]]></content:encoded>
			<wfw:commentRss>http://ariekanarie.nl/archives/107/switching-from-ubuntuwindows-to-mac-os-x/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mod_rails vs thin vs ebb vs mongrel</title>
		<link>http://ariekanarie.nl/archives/51/mod_rails-vs-thin-vs-ebb-vs-mongrel</link>
		<comments>http://ariekanarie.nl/archives/51/mod_rails-vs-thin-vs-ebb-vs-mongrel#comments</comments>
		<pubDate>Wed, 16 Apr 2008 09:29:22 +0000</pubDate>
		<dc:creator>Arie</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://ariekanarie.nl/?p=51</guid>
		<description><![CDATA[With the recent release of mod_rails, I thought it was time for yet another benchmark. Mod_rails aims to make deployment of RubyOnRails applications comparable to deploying a PHP application on a shared host. The contestants mod_rails (Apache 2.2.8) Thin 0.8.0 (Cluster of 4 behind nginx 0.5.33, both TCP and Unix socket) Ebb 0.1.0 (Cluster of [...]]]></description>
			<content:encoded><![CDATA[<p>With the recent release of <a href="http://modrails.com" target="_blank">mod_rails</a>, I thought it was time for <a href="http://ariekanarie.nl/archives/45/yet-another-ruby-server" target="_blank">yet</a> <a href="http://ariekanarie.nl/archives/44/ruby-web-server-performance" target="_blank">another</a> benchmark. Mod_rails aims to make deployment of RubyOnRails applications comparable to deploying a PHP application on a shared host.</p>
<p><strong>The contestants</strong></p>
<p>mod_rails (Apache 2.2.8)</p>
<p>Thin 0.8.0 (Cluster of 4 behind nginx 0.5.33, both TCP and Unix socket)</p>
<p>Ebb 0.1.0 (Cluster of 4 behind nginx 0.5.33)</p>
<p>Mongrel 1.1.4 (Cluster of 4 behind nginx 0.5.33)</p>
<p>The benchmark is the index page of <a href="http://leefjedoel.nl" target="_blank">Leef je doel</a>, the hardware used is a Dell D830 laptop with a T7300 (speedstep disabled), 2GB of RAM and a 7200RPM harddisk. The page runs a few queries and also serves a lot of fragments from memcached.</p>
<p><strong>The results</strong></p>
<p><a href="http://ariekanarie.nl/wordpress/wp-content/uploads/2008/04/image001.png" rel="lightbox"><img class="alignnone size-full wp-image-52" title="mod_rails vs thin vs ebb vs mongrel" src="http://ariekanarie.nl/wordpress/wp-content/uploads/2008/04/image001.png" alt="" width="482" height="289" /></a></p>
<table border="0">
<tbody>
<tr>
<td></td>
<td><strong>-n 10000 -c 10<br />
</strong></td>
<td><strong> -n 10000 -c 50</strong></td>
</tr>
<tr>
<td>mod_rails</td>
<td>79.2</td>
<td>77.4</td>
</tr>
<tr>
<td>thin(tcp)</td>
<td>84.22</td>
<td>84.06</td>
</tr>
<tr>
<td>thin(socket)</td>
<td>86.4</td>
<td>87.65</td>
</tr>
<tr>
<td>ebb</td>
<td>93.2</td>
<td>91.2</td>
</tr>
<tr>
<td>mongrel</td>
<td>79.22</td>
<td>75.92</td>
</tr>
</tbody>
</table>
<p><strong>Performance</strong></p>
<p>Like my previous test, Ebb comes out on top, closely followed by Thin.</p>
<p>Using the default Apache2 config supplied by Ubuntu, mod_rails shows performance equal to mongrel_cluster behind nginx. I&#8217;m sure that by tweaking the Apache config files, some performance can be gained.</p>
<p>Compared to setting up nginx and thin/ebb/mongrel, setting up mod_rails is a lot simpler. Have a look at <a href="http://www.railsplugins.net/passenger.mov" target="_blank">their screencast</a> to see how easy it is, if you have a working Apache2, you&#8217;ll have mod_rails up and running within minutes. There are some small issues with mod_rails at the moment, for a list, check <a href="http://code.google.com/p/phusion-passenger/issues/list" target="_blank">mod_rails&#8217; Google Code page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ariekanarie.nl/archives/51/mod_rails-vs-thin-vs-ebb-vs-mongrel/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
<enclosure url="http://www.railsplugins.net/passenger.mov" length="18988364" type="video/quicktime" />
		</item>
		<item>
		<title>Using MemCached to speed up fragment caching</title>
		<link>http://ariekanarie.nl/archives/46/using-memcached-to-speed-up-fragment-caching</link>
		<comments>http://ariekanarie.nl/archives/46/using-memcached-to-speed-up-fragment-caching#comments</comments>
		<pubDate>Wed, 02 Apr 2008 17:56:04 +0000</pubDate>
		<dc:creator>Arie</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://ariekanarie.nl/?p=148</guid>
		<description><![CDATA[Like any web 2.0 site, leefjedoel.nl is currently in beta. During this phase we&#8217;re trying to find bottlenecks, fix the last few bugs and optimize heavy parts of the site. During development we already prepared caching for all pages, mostly fragment caching. To expire cache that&#8217;s no longer current, we use sweepers that get called [...]]]></description>
			<content:encoded><![CDATA[<p>Like any web 2.0 site, <a title="leefjedoel.nl" href="http://leefjedoel.nl" target="_blank">leefjedoel.nl</a> is currently in beta. During this phase we&#8217;re trying to find bottlenecks, fix the last few bugs and optimize heavy parts of the site.</p>
<p>During development we already prepared caching for all pages, mostly fragment caching. To expire cache that&#8217;s no longer current, we use sweepers that get called when something relevant is updated. These sweepers only sweep the caches that get outdated.</p>
<p>Because we were unfamiliar with caching and needed to see the result of our fragment caching, we used the file_store to store the generated caches. These files are stored on disk and this way you can easily see how many cache gets generated and what they contain.</p>
<p><strong>Regex and file_store == FAIL</strong></p>
<p>To sweep caches we used regular expressions, this way we could easily sweep all relevant caches at once. This was a bad idea, as you can read <a title="Caching makes your brain explode" href="http://blog.craigambrose.com/past/2007/11/13/caching_makes_your_brain_explode/" target="_blank">here</a> and <a title="Rails expire_fragment(regex) Considered Harmful" href="http://gurge.com/blog/2007/02/04/rails-expire_fragmentregex-considered-harmful/" target="_blank">here</a></p>
<p>During the beta phase the size of the site steadily increased, more users, more goals, more groups. There was a noticeable delay whenever you updated/created something. A short investigation pointed to the cache sweepers as the culprit.</p>
<p>The file_store for cache isn&#8217;t exactly the fastest solution to store your cache, but when you combine it with regex sweepers, things really slow down. Whenever you do a regex sweep, all files in the cache directory get returned (not that surprising if you think of it), and the regex is run against it. So even if you do a sweep on /goals, it will also return files in /users and /groups. As a result, updating your profile could take 15 seconds.</p>
<p><strong>MemCached</strong></p>
<p>We&#8217;d been planning on moving the cache to memcached all along, so this seemed a good opportunity to do it. In the next few paragraphs I&#8217;ll describe how to install memcached, get the correct Rails plugin to make memcached play nice with fragment caching and how to configure your Rails application so it uses your memcache server.</p>
<p><strong>Installation of MemCached on GNU/Linux</strong></p>
<p>First of all, you&#8217;ll need to memcache daemon, assuming you have a nice linux distro you can:</p>
<blockquote><p>sudo apt-get install memcached</p></blockquote>
<p>This will work on Debian, Ubuntu and other Debian-based distro&#8217;s, on Gentoo you can</p>
<blockquote><p>emerge memcached</p></blockquote>
<p>The great thing about memcached is its simplicity, it requires no configuration after installation, just run it.</p>
<p><strong>All about the gems baby</strong></p>
<p>Now we&#8217;ll get the gem to allow Ruby to talk to memcache. There are two gems that do this, Ruby-MemCache and memcache-client. memcache-client is supposed to be faster, so I used that.</p>
<blockquote><p>sudo gem install memcache-client</p></blockquote>
<p><strong>Plugin to play nice with rails</strong></p>
<p>Rails&#8217; fragment caching doesn&#8217;t work with memcached out of the box, you&#8217;ll need a plugin. This plugin also adds a nice bonus to the cache method in views.</p>
<blockquote><p>script/plugin install svn://rubyforge.org/var/svn/zventstools/projects/extended_fragment_cache</p></blockquote>
<div><strong>Environment setup</strong></div>
<p>Now we need to configure your Rails app to use the memcached server. You&#8217;ll need to edit your config/environments/production.rb</p>
<pre name="code" class="ruby">memcache_options = {
:c_threshold = 10_00,
:compression = true,
:debug = false,
:namespace = 'yourappname_or_anything_you_like',
:readonly = false,
:urlencode = false
}
CACHE = MemCache.new(memcache_options)
CACHE.servers = '127.0.0.1:11211'
config.action_controller.fragment_cache_store = CACHE, {}
</pre>
<p><strong>That&#8217;s all folks!</strong></p>
<p>That&#8217;s it, you&#8217;re all done, the &#8216;cache&#8217; method in your views will now use the memcache server.</p>
<p><strong>Oh wait, there&#8217;s an encore</strong></p>
<p>But there&#8217;s more, using memcached you can set expiry times for caches. I edited the plugin for a default expiry time of 1 day. In vendor/plugins/extended_fragment_cache/lib/extended_fragment_cache.rb look for def write(key,content,options=nil)</p>
<pre name="code" class="ruby">
def write(key,content,options=nil)
  expiry = options &amp;&amp; options[:expire] || 1.day
  begin
    set(key,content,expiry)
    rescue ActiveRecord::Base.logger.error("MemCache Error: #{$!}")
    rescue MemCache::MemCacheError = err
    ActiveRecord::Base.logger.error("MemCache Error: #{$!}")
  end
end
</pre>
<p>You can change the 1.day to anything you want. To override this default behaviour, you can use the following code in your views</p>
<pre name="code" class="ruby">
cache('goals/large_cloud', {:expire = 30.minutes.to_i})  do
</pre>
<p>This will make the cache called &#8216;goals/large_cloud&#8217; to expire 30 minutes after it got created.</p>
<p>There are two important things to consider when you move to memcached</p>
<blockquote><p>1. MemCached doesn&#8217;t support regex based expiry of caches. You need to manually enter every cache you want to expire. You can do this in some nice methods of course. Here&#8217;s ours for expiring the cache when a user gets updated.</p>
<pre name="code" class="ruby">
def expire_user_fragments(user)
  fragments = %w[author_icon author_link side_block_friends ..snip...]
  fragments.each do |f|
    expire_fragment("user/#{user.id}/#{f}")
  end
end</pre>
<p>2. Your application will fail when the MemCache server becomes unavailable. If you ever restart MemCache, or if it crashes (haven&#8217;t seen that happen yet), you need to restart your mongrel-cluster/thin/ebb.</p>
<p>3. When you restart MemCache, all cache is cleared, and you need to restart your mongrel-cluster/thin/ebb.</p></blockquote>
<p>This guide only talks about fragment caching, over at <a href="http://www.bencurtis.com/archives/2007/12/painless-rails-action-caching-with-memcached/#more-111">Ben Curtis&#8217; blog</a>, you can read all about action caching.</p>
]]></content:encoded>
			<wfw:commentRss>http://ariekanarie.nl/archives/46/using-memcached-to-speed-up-fragment-caching/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Yet another Ruby server</title>
		<link>http://ariekanarie.nl/archives/45/yet-another-ruby-server</link>
		<comments>http://ariekanarie.nl/archives/45/yet-another-ruby-server#comments</comments>
		<pubDate>Tue, 04 Mar 2008 15:55:13 +0000</pubDate>
		<dc:creator>Arie</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[ebb]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[thin]]></category>

		<guid isPermaLink="false">http://ariekanarie.nl/archives/145/yet-another-ruby-server</guid>
		<description><![CDATA[Ruby Inside just posted a pretty impressive performance graph of a new Ruby server called Ebb. The graph was taken from the homepage of Ebb Now what is Ebb? The design is similar to the Evented Mongrel web server; except instead of using EventMachine (a ruby binding to libevent), the Ebb web server is written [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ariekanarie.nl/wordpress/wp-content/uploads/2008/03/concurrency.png" title="Ebb bench" rel="lightbox"><img src="http://ariekanarie.nl/wordpress/wp-content/uploads/2008/03/concurrency.thumbnail.png" alt="Ebb bench" align="right" /></a><a href="http://www.rubyinside.com/ebb-web-framework-http-server-786.html" title="Ruby Inside" target="_blank">Ruby Inside</a> just posted a pretty impressive performance graph of a new Ruby server called Ebb. The graph was taken from the <a href="http://ebb.rubyforge.org/" target="_blank">homepage of Ebb</a></p>
<p>Now what is Ebb?</p>
<blockquote><p>The design is similar to the  <a href="http://swiftiply.swiftcore.org/mongrel.html">Evented Mongrel</a> web server;  except instead of using EventMachine (a ruby binding to libevent), the Ebb  web server is written in C and uses the  <a href="http://software.schmorp.de/pkg/libev.html">libev</a> event loop library.</p>
<p>Connections are processed as follows:</p>
<ol>
<li>libev loops and waits for incoming connections.</li>
<li>When Ebb receives a connection, it passes the request into the <a href="http://mongrel.rubyforge.org/browser/tags/rel_1-0-1/ext/http11/http11_parser.rl">mongrel state machine</a>  which securely parses the headers.</li>
<li>When the request is complete, Ebb passes the information to a user supplied callback.</li>
<li>The Ruby binding supplying this callback transforms the request into a <a href="http://rack.rubyforge.org/">Rack</a> compatible <code>env</code> hash  and passes it on a Rack adapter.</li>
</ol>
</blockquote>
<p>The graph describes performance of a simple rack application and compares Ebb to mongrel, evented mongrel and thin. I&#8217;m more interested in performance with a Rails application and decided to do a benchmark for that.</p>
<p>In my benchmark I used the same application I used for <a href="http://ariekanarie.nl/archives/142/ruby-web-server-performance" target="_blank">my previous benchmark</a>, only this time I benchmarked some extra pages.</p>
<p>Page 1 is a heavily cached page with few dynamic elements</p>
<p>Page 2 is a less cached page with a bit more dynamic elements</p>
<p>Page 3 is a non-cached page with an N+1 performance issue.</p>
<p>Ebb was tested using version 0.0.3, while Thin was on version 0.7.0. Both were run in a cluster of 4 behing nginx as a load balancer.</p>
<p><a href="http://ariekanarie.nl/wordpress/wp-content/uploads/2008/03/image001.png" title="Ebb vs Thin benchmark" rel="lightbox"><img src="http://ariekanarie.nl/wordpress/wp-content/uploads/2008/03/image001.png" alt="Ebb vs Thin benchmark" /></a></p>
<p>Interestingly Ebb managed to outperform Thin by about 10% on every page.</p>
]]></content:encoded>
			<wfw:commentRss>http://ariekanarie.nl/archives/45/yet-another-ruby-server/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Ruby web server performance</title>
		<link>http://ariekanarie.nl/archives/44/ruby-web-server-performance</link>
		<comments>http://ariekanarie.nl/archives/44/ruby-web-server-performance#comments</comments>
		<pubDate>Tue, 19 Feb 2008 21:53:58 +0000</pubDate>
		<dc:creator>Arie</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[thin]]></category>

		<guid isPermaLink="false">http://ariekanarie.nl/archives/142/ruby-on-rails-performance</guid>
		<description><![CDATA[I&#8217;m currently helping a colleague to build a rather large community website using Ruby on Rails. As most Rails developers are well aware, Ruby isn&#8217;t exactly the quickest language you can use to build web applications. To get a rough idea of how much users our current code would handle, I decided to run some [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently helping a <a href="http://infx.nl" title="Iain's blog">colleague </a>to build a rather large community website using Ruby on Rails. As most Rails developers are well aware, Ruby isn&#8217;t exactly the quickest language you can use to build web applications. To get a rough idea of how much users our current code would handle, I decided to run some performance tests.</p>
<p>First, here&#8217;s a picture of the page that was used.</p>
<p><a href="http://ariekanarie.nl/wordpress/wp-content/uploads/2008/02/benched_site.gif" title="Leef je Doel index page" rel="lightbox"><img src="http://ariekanarie.nl/wordpress/wp-content/uploads/2008/02/benched_site.thumbnail.gif" alt="Leef je Doel index page" /></a></p>
<p>The page has a tagcloud, site statistics and a conditional menu in the upper right corner.</p>
<p>For the benchmark I&#8217;m using the following tools</p>
<blockquote><p>ApacheBench 2.0.40. To fire off a large amount of requests into the webserver.</p>
<p>Mongrel 1.1.3. One of the Ruby web servers</p>
<p>Thin 0.6.4. An alternative to Mongrel.</p>
<p>nginx 0.5.26. A lightweight HTTP server, which will act as a proxy/balancer in front of the Ruby application servers</p></blockquote>
<p>For the benchmarks I settled on the following scenario&#8217;s.</p>
<blockquote><p>Single instance of Mongrel in development mode</p>
<p>Single instance of Mongrel in production mode</p>
<p>Cluster of 4 Mongrel instances behind nginx</p>
<p>Cluster of 4 Thin instances behind nginx</p></blockquote>
<p>In a real production environment, you&#8217;d never see the single Mongrel instance, and certainly not in development mode. The graph will show you why.</p>
<p>The red bar is for 50 concurrent requests, with a total of 10000.  The red blue is for 10 concurrent requests, with a total of 10000.</p>
<p><a href="http://ariekanarie.nl/wordpress/wp-content/uploads/2008/02/bench_graph.PNG" title="Benchmark graph" rel="lightbox"><img src="http://ariekanarie.nl/wordpress/wp-content/uploads/2008/02/bench_graph.PNG" alt="Benchmark graph" /></a></p>
<p>The raw numbers:</p>
<table>
<tr>
<td>&nbsp;</td>
<td><strong>10 concurrent</strong></td>
<td><strong>50 concurrent</strong></td>
</tr>
<tr>
<td>Mongrel (development)</td>
<td>4.88 req/s</td>
<td>4.59 req/s</td>
</tr>
<tr>
<td>Mongrel (production)</td>
<td>77.15 req/s</td>
<td>67.18 req/s</td>
</tr>
<tr>
<td>Mongrel cluster + nginx</td>
<td>130.97 req/s</td>
<td>122.04 req/s</td>
</tr>
<tr>
<td>Thin + nginx</td>
<td>156.21 req/s</td>
<td>160.89 req/s</td>
</tr>
</table>
<p>I&#8217;m pleased with the results, we still have a lot of stuff we could cache and database queries that could be optimized, so there&#8217;s room for improvement. The server that will eventually host the application runs an Apache proxy going to mongrel_cluster. I&#8217;m probably going to run some benchmarks later, to see how Apache proxy holds up against nginx.</p>
]]></content:encoded>
			<wfw:commentRss>http://ariekanarie.nl/archives/44/ruby-web-server-performance/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Syntax highlighting for plain text user stories</title>
		<link>http://ariekanarie.nl/archives/39/syntax-highlighting-for-plain-text-user-stories</link>
		<comments>http://ariekanarie.nl/archives/39/syntax-highlighting-for-plain-text-user-stories#comments</comments>
		<pubDate>Tue, 18 Dec 2007 14:33:43 +0000</pubDate>
		<dc:creator>Arie</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[highlighting]]></category>
		<category><![CDATA[plain]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[stories]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://ariekanarie.nl/archives/115/syntax-highlighting-for-plain-text-user-stories</guid>
		<description><![CDATA[Again a post about plain text user stories My friend Iain was busy making syntax highlighting in VIm for rSpec&#8217;s plain text user stories. I thought it would be nice to modify the Google Syntax Highlighting plugin for WordPress, so you can have nicely highlighted stories on your blog. First install the WordPress plugin and [...]]]></description>
			<content:encoded><![CDATA[<p>Again a post about <a href="http://ariekanarie.nl/archives/95/story-based-acceptance-testing" target="_blank">plain text user stories</a></p>
<p>My friend Iain was busy making <a href="http://infx.nl/2007/12/18/plain-text-stories-and-vim/" target="_blank">syntax highlighting in VIm for rSpec&#8217;s plain text user stories</a>. I thought it would be nice to modify the<a href="http://wordpress.org/extend/plugins/google-syntax-highlighter/" target="_blank"> Google Syntax Highlighting plugin for WordPress</a>, so you can have nicely highlighted stories on your blog.</p>
<p>First install the WordPress plugin and make sure it works. After, download <a href="http://ariekanarie.nl/wordpress/wp-content/uploads/2007/12/storysyntaxtar.bz2" title="Modified google syntax highlighting.">my modified version of this plugin.</a></p>
<p>Whenever you want to post a plain-text user story, use the pre tag with &#8216;code&#8217; as name and &#8216;story&#8217; as class attribute to indicate it&#8217;s a user story.</p>
<p>This is how it looks:</p>
<pre name="code" class="story">
Story: Arrangement

As a user
I want to invite people
So I have more chance of winning an arrangement

Scenario: Browsing the homepage
Given a clean database
When the user goes to /
Then the page should contain the text 'alledaagse'

Scenario: Choosing an arrangement
When the user chooses the godinfrankrijk arrangement
Then the page should contain the text 'God in Frankrijk'
And the page should contain the text 'voor te stellen'

Scenario: Inviting a person
Given a clean session
When the user chooses the ster arrangement
Then the page should contain the text 'leven als een ster'
When the user types 'His Name' into the invitee_name field
And the user types 'Street 13' into the invitee_address field
And the user types '1234AB' into the invitee_zip field
And the user types 'Rotterdam' into the invitee_city field
And the user types '0101234567' into the invitee_phone field
And the user clicks on the radiobutton labelled vrouw
And the user clicks the submit button
Then the page should contain the text 'mijn gegevens'</pre>
]]></content:encoded>
			<wfw:commentRss>http://ariekanarie.nl/archives/39/syntax-highlighting-for-plain-text-user-stories/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Busy on Rails</title>
		<link>http://ariekanarie.nl/archives/38/busy-on-rails</link>
		<comments>http://ariekanarie.nl/archives/38/busy-on-rails#comments</comments>
		<pubDate>Sat, 15 Dec 2007 19:02:05 +0000</pubDate>
		<dc:creator>Arie</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[als]]></category>
		<category><![CDATA[indivirtual]]></category>
		<category><![CDATA[leven]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://ariekanarie.nl/archives/113/busy-on-rails</guid>
		<description><![CDATA[Had a rather busy week hacking together a site in Rails. My friend and colleague Iain wrote about that project on his blog. I&#8217;m very pleased with the end result, and I hope the customer will be as well. We&#8217;ll find out next week function flashIsExit() { window.location = "http://www.levenals.nl/winnen_of_doorsturen.html"; }]]></description>
			<content:encoded><![CDATA[<p><a href="http://ariekanarie.nl/wordpress/wp-content/uploads/2007/12/levenals.png" title="Leven als…" rel="lightbox"><img src="http://ariekanarie.nl/wordpress/wp-content/uploads/2007/12/levenals.thumbnail.png" alt="Leven als…" align="right" hspace="20" vspace="20" /></a>Had a rather busy week hacking together a site in Rails. My friend and colleague Iain <a href="http://infx.nl/2007/12/14/the-agile-grail-and-the-knights-templater/" target="_blank">wrote about that project</a> on his blog.</p>
<p>I&#8217;m very pleased with the end result, and I hope the customer will be as well.</p>
<p>We&#8217;ll find out next week <img src='http://ariekanarie.nl/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <span id="more-38"></span></p>
<p><script> function flashIsExit() {   window.location = "http://www.levenals.nl/winnen_of_doorsturen.html"; } </script><br />
<object height="303" width="404"><param name="allowScriptAccess" value="always"></param><param name="movie" value="http://dela.dnbmedia.com/skydive/SkyDive.swf?plaats=Rotterdam&amp;adres=Van Zandvlietplein&amp;huisnummer=1"></param> <embed src="http://dela.dnbmedia.com/skydive/SkyDive.swf?plaats=Rotterdam&amp;adres=Van%20Zandvlietplein&amp;huisnummer=1" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" height="303" width="404"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://ariekanarie.nl/archives/38/busy-on-rails/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nvidia GPU temperature screenlet</title>
		<link>http://ariekanarie.nl/archives/36/nvidia-gpu-temperature-screenlet</link>
		<comments>http://ariekanarie.nl/archives/36/nvidia-gpu-temperature-screenlet#comments</comments>
		<pubDate>Thu, 06 Dec 2007 16:29:15 +0000</pubDate>
		<dc:creator>Arie</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[nvidia]]></category>
		<category><![CDATA[screenlet]]></category>
		<category><![CDATA[temperature]]></category>

		<guid isPermaLink="false">http://ariekanarie.nl/archives/101/nvidia-gpu-temperature-screenlet</guid>
		<description><![CDATA[Today I rediscovered screenlets for Ubuntu. If you don&#8217;t know what screenlets are, click on the thumbnail on the right. On my old laptop I tried using them before, but the poor thing couldn&#8217;t handle it. Now with my new laptop I decided to give it another go. Using compiz-fusion you can put these screenlets [...]]]></description>
			<content:encoded><![CDATA[<p><a title="All screenlets" href="http://ariekanarie.nl/wordpress/wp-content/uploads/2007/12/screenlets.png" rel="lightbox"><img src="http://ariekanarie.nl/wordpress/wp-content/uploads/2007/12/screenlets.thumbnail.png" alt="All screenlets" align="right" /></a>Today I rediscovered screenlets for Ubuntu.  If you don&#8217;t know what screenlets are, click on the thumbnail on the right.</p>
<p>On my old laptop I tried using them before, but the poor thing couldn&#8217;t handle it.</p>
<p>Now with my new laptop I decided to give it another go.</p>
<p>Using compiz-fusion you can put these screenlets on a special &#8216;widget layer&#8217;, which you can summon by pressing a keyboard key. <img src="http://ariekanarie.nl/wordpress/wp-content/uploads/2007/12/temperature-screenlets.png" alt="Temperature screenlets" hspace="5" vspace="5" align="right" />Whenever you need some information or need to make a small note, you press that keyboard key and the widget layer is displayed. Pressing the same key again and the widgets disappear.</p>
<p>There&#8217;s a nice screenlet that displays some sensor information, CPU and HDD temperatures. However, my laptop has another sensor on the graphics card that shows the GPU temperature. I just had to have this added to the screenlet.</p>
<p><span style="text-decoration: line-through;"><a title="Modified temperatures script" href="http://ariekanarie.nl/wordpress/wp-content/uploads/2007/12/temperature2screenlet.py">I made a modified version of the Temperature2 script</a></span> to generate a screenlet for nvidia GPU temperature. You&#8217;ll need the proprietary nvidia drivers installed and access to the &#8216;nvidia-settings&#8217; utility. Download the file and place it in the ~/.screenlets/Temperature2/ directory, overwriting the old file.</p>
<p><strong>Update: My modifications are now included into version 0.4 of Temperature2. You can get it at <a href="http://screenlets.org/index.php/Temperature2" target="_blank">screenlets.org</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://ariekanarie.nl/archives/36/nvidia-gpu-temperature-screenlet/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Book on BDD in Ruby with RSpec</title>
		<link>http://ariekanarie.nl/archives/34/book-on-bdd-in-ruby-with-rspec</link>
		<comments>http://ariekanarie.nl/archives/34/book-on-bdd-in-ruby-with-rspec#comments</comments>
		<pubDate>Thu, 15 Nov 2007 13:35:39 +0000</pubDate>
		<dc:creator>Arie</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[aslak]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[dave astels]]></category>
		<category><![CDATA[david chelimsky]]></category>
		<category><![CDATA[hellesoy]]></category>
		<category><![CDATA[plain text stories]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://ariekanarie.nl/wordpress/archives/97</guid>
		<description><![CDATA[I was browsing through this excellent presentation given by Dave Astels and David Chelimsky at RubyConf2007. Turns out that David Chelimsky and Aslak Hellesøy are working on a book about Behaviour Driven Development using RSpec. The presentation is an excellent introduction for anyone thinking about moving to RSpec. It tells you a bit about the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ariekanarie.nl/wordpress/wp-content/uploads/2007/11/rspec_book.png" title="RSpec book" rel="lightbox"><img src="http://ariekanarie.nl/wordpress/wp-content/uploads/2007/11/rspec_book.thumbnail.png" alt="RSpec book" align="right" /></a></p>
<p>I was browsing through this <a href="http://blog.davidchelimsky.net/files/BDDWithRspec.RubyConf.2007.pdf" target="_blank">excellent presentation</a> given by <a href="http://daveastels.com/" target="_blank">Dave Astels</a> and <a href="http://blog.davidchelimsky.net/" target="_blank">David Chelimsky</a> at RubyConf2007. Turns out that David Chelimsky and <a href="http://blog.aslakhellesoy.com/" target="_blank">Aslak Hellesøy</a> are working on a book about Behaviour Driven Development using RSpec.</p>
<p>The presentation is an excellent introduction for anyone thinking about moving to RSpec. It tells you a bit about the (rather short) history of the framework and the differences between BDD and TDD.</p>
<p>It also shows off the awesome plain-text stories I posted about earlier.</p>
]]></content:encoded>
			<wfw:commentRss>http://ariekanarie.nl/archives/34/book-on-bdd-in-ruby-with-rspec/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
