<?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>Cantina Consulting &#187; Ruby on Rails</title>
	<atom:link href="http://www.cantinaconsulting.com/category/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cantinaconsulting.com</link>
	<description></description>
	<lastBuildDate>Tue, 27 Jul 2010 18:47:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Web Applications &#8211; What does it take?</title>
		<link>http://www.cantinaconsulting.com/2009/05/18/web-applications-what-does-it-take/</link>
		<comments>http://www.cantinaconsulting.com/2009/05/18/web-applications-what-does-it-take/#comments</comments>
		<pubDate>Mon, 18 May 2009 18:56:18 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[startups]]></category>
		<category><![CDATA[web applications]]></category>

		<guid isPermaLink="false">http://www.cantinaconsulting.com/?p=150</guid>
		<description><![CDATA[One of the founders of Woofoo just wrote a terrific article on what it takes to build a web application called &#8220;Web App Autopsy&#8220;.  They were lucky enough to get some great information from three other firms, Blinksale, Feedburner and RegOnline.  I think the charts and information they put together are great, but if you [...]]]></description>
			<content:encoded><![CDATA[<p>One of the founders of Woofoo just wrote a terrific article on what it takes to build a web application called &#8220;<a href="http://particletree.com/features/web-app-autopsy/" target="_blank">Web App Autopsy</a>&#8220;.  They were lucky enough to get some great information from three other firms, <a href="http://www.blinksale.com" target="_blank">Blinksale</a>, <a href="http://www.feedburner.com" target="_blank">Feedburner</a> and <a href="http://www.regonline.com" target="_blank">RegOnline</a>.  I think the charts and information they put together are great, but if you dig into the numbers a little deeper you start to see what it really takes to build a web application.</p>
<p>From a time perspective (you have to exclude RegOnline because it was a nights a weekend project) it takes on average about 5 months to launch one of these applications and you need roughly 3 or 4 engineers to get it done.  My guess is that most of these companies boot strapped their development but current estimates say developing a web application costs anywhere from 50k to a few hundred based on complexity.  It&#8217;s also great to see these rapid development frameworks, such as Ruby on Rails, are accelerating development and time to market.</p>
<p>Lastly, I would also emphasize their focus on business processes. Many early stage companies completely neglect support needs, such as returns, customer compliants, etc.  It can end up costing you a lot of time and money if you don&#8217;t have systems on the back end to handle customer support issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cantinaconsulting.com/2009/05/18/web-applications-what-does-it-take/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gotchas in using BackgrounDRb in Ruby on Rails</title>
		<link>http://www.cantinaconsulting.com/2008/04/22/gotchas-in-using-backgroundrb-in-ruby-on-rails/</link>
		<comments>http://www.cantinaconsulting.com/2008/04/22/gotchas-in-using-backgroundrb-in-ruby-on-rails/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 03:02:12 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.cantinaconsulting.com/2008/04/22/gotchas-in-using-backgroundrb-in-ruby-on-rails/</guid>
		<description><![CDATA[I&#8217;ve been working on a bit of code to perform audio and video encoding for media files uploaded to one of our client&#8217;s sites and I was thrilled to come across BackgrounDRb, a Rails plugin that allows developers to build scheduled background tasks, similar to the OpenSympony&#8217;s Quartz for Java. The plugin also allows you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a bit of code to perform audio and video encoding for media files uploaded to one of our client&#8217;s sites and I was thrilled to come across BackgrounDRb, a Rails plugin that allows developers to build scheduled background tasks, similar to the OpenSympony&#8217;s <a href="http://www.opensymphony.com/quartz/">Quartz</a> for Java. The plugin also allows you to allow user actions to initiate long running processes by spawning worker threads from controllers (or other places).</p>
<p>Of particular interest to me was the ability to spawn (fork) worker threads from user actions, or in this case, ActiveRecord callbacks which were called when the user action caused my model object to be saved. The basic order of operations is this:</p>
<ol>
<li>User uploads an audio file</li>
<li>Uploaded file data is loaded into an attachment_fu model object</li>
<li>Model object is saved</li>
<li>Model object&#8217;s after_save callback is called</li>
<li>The after_save callback determines whether the uploaded file requires encoding, and spawns a BackgrounDRb worker process if it does</li>
</ol>
<p>In this process lay many issues. I&#8217;ve attempted to describe some of them below.</p>
<p><strong>Close your connections</strong></p>
<p>This may be obvious to many, but I figured with all that ActiveRecord does for you, that if I do some work with ActiveRecord in a BackgrounDRB worker process, my database connections would be closed automatically. This was not the case, however it can be quickly remedied by adding the following after all your code is done doing what it needs to do:</p>
<p>ActiveRecord::Base.connection.disconnect!</p>
<p><strong>Don&#8217;t try to pass entire ActiveRecord objects to workers from Rails</strong></p>
<p>I started building a simple call to spawn a new BackgrounDRb worker from an ActiveRecord lifecycle callback method (see below), and starting running into errors like these:</p>
<pre>
undefined method `[]' for #&lt;DRb::DRbUnknown:0x2501bd4&gt;
</pre>
<p></p>
<p>I found a number of postings online indicating that simply adding the following to my model objects would clear this up:</p>
<pre>
include DRbUndumped
</pre>
<p>Doing so did not fix my undefined method problems, so when I came across this on another blog, I decided to cut my losses and just pass the database ID.</p>
<blockquote>
<p><span style="font-weight: normal;">When passing arguments from Rails to BackgrounDRb workers, don’t pass huge ActiveRecord objects. Its asking for trouble. You can easily circumvent the situation by passing id of AR objects.<a href="http://gnufied.org/2008/02/12/backgroundrb-best-practises/"></a></span></p>
<p>From: <a href="http://gnufied.org/2008/02/12/backgroundrb-best-practises/">BackgrounDRb best practises</a></p>
</blockquote>
<p>One thing that I didn&#8217;t think I&#8217;d be dealing with in coming to Rails from a Java background is serialization issues, but there we have it.</p>
<p><strong>Don&#8217;t create new workers from new record callbacks</strong></p>
<p>This may have been common knowledge, but I had to discover this the hard way. The after_save callback in ActiveRecord model objects is called before the save transaction has been committed. The implication this has is that if I pass an ID of an ActiveRecord object to BackgrounDRb for further processing, strange things can happen.</p>
<p>In the case of my after_save callback being called on a newly created object, I found that most of the time, by the time the BackrounDRb process starts working and tries to retrieve the object using the ID I have passed, my original object.save() transaction has not yet committed, so I get errors indicating the record could not be found, even though I check the database no more than a second later and the record is there and intact.<br />
It seems that I&#8217;m not the only one that was looking for a post-commit callback:</p>
<ul>
<li><a href="http://elimiller.blogspot.com/2007/06/proper-cache-expiry-with-aftercommit.html">Proper cache expiry with after_commit</a><a href="http://localhost3000.de/2008/02/12/a-good-thing-to-know-after_save-sits-inside-the-transaction/"></a></li>
<li><a href="http://localhost3000.de/2008/02/12/a-good-thing-to-know-after_save-sits-inside-the-transaction/">A good thing to know: after_save sits inside the transaction</a></li>
</ul>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cantinaconsulting.com/2008/04/22/gotchas-in-using-backgroundrb-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
