<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Ruby Background Tasks with Starling - Part 3</title>
	<atom:link href="http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/feed/" rel="self" type="application/rss+xml" />
	<link>http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/</link>
	<description>Some random thoughts - Go big or stay home!</description>
	<pubDate>Thu, 20 Nov 2008 21:04:15 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Dave</title>
		<link>http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-265</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Wed, 29 Oct 2008 13:29:43 +0000</pubDate>
		<guid isPermaLink="false">http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-265</guid>
		<description>I have a couple more I can add. I've been pretty lax of late, but comments tend to get me back going again.</description>
		<content:encoded><![CDATA[<p>I have a couple more I can add. I&#8217;ve been pretty lax of late, but comments tend to get me back going again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil</title>
		<link>http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-264</link>
		<dc:creator>Neil</dc:creator>
		<pubDate>Wed, 29 Oct 2008 08:14:09 +0000</pubDate>
		<guid isPermaLink="false">http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-264</guid>
		<description>Yes, if Starling is working for you, and it's already proven to be very simple and reliable what my own experiences, it'll do just fine, for now. The guys at Engine Yard seem to be happy with it (after getting over some niggling config with Monit). 

I think the team at Twitter have done a fantastic job of late. The app I'm working on has some resemblances to Twitter &#38; it's status updates, so that's another reason to use Starling. 

I'm looking forward to any more Rails &#38; background process related posts.</description>
		<content:encoded><![CDATA[<p>Yes, if Starling is working for you, and it&#8217;s already proven to be very simple and reliable what my own experiences, it&#8217;ll do just fine, for now. The guys at Engine Yard seem to be happy with it (after getting over some niggling config with Monit). </p>
<p>I think the team at Twitter have done a fantastic job of late. The app I&#8217;m working on has some resemblances to Twitter &amp; it&#8217;s status updates, so that&#8217;s another reason to use Starling. </p>
<p>I&#8217;m looking forward to any more Rails &amp; background process related posts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-263</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Mon, 27 Oct 2008 17:56:26 +0000</pubDate>
		<guid isPermaLink="false">http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-263</guid>
		<description>This really hard to say given that the two apps in question were so different.  I would say that ActiveMQ/ActiveMessaging (JMS) will most like perform better given all the code in Java vs. Ruby (perform being separate from scale).  The JMS solution, however, is far more complex and suited for the Enterprise.  Note, this is not to say that Starling can't scale. It will just scale differently and with different issues to content with.  If anything, since Starling instances are completely independent, you can scale horizontally almost at will.  That's what Twitter does with it, and regardless of what you may think about Twitter, they do scale pretty well.

My experience has been that message flow has never been the issue. It's always message processing that is the problem.  My bias will always be towards a solution like Starling because it's simpler.  Unless I have a need for absolutely guaranteed message delivery or have huge message backups, I don't see a reason to introduce Java, ActiveMQ, and ActiveMessaging to the mix.  I reference huge message backups because Starling is basically a persisted memory queue.  If your queue gets too backed up, you will run out of memory.  JMS has many modes that allow for queue to grow far larger than available memory if necessary.

One more thing, Rails is still not able to handle distributed transactions easily, so the absolute guarantee with ActiveMQ is not happening anyway.  You will need to write additional code to handle failures rather than relying on transactional rollback like you can in Java and other platforms.</description>
		<content:encoded><![CDATA[<p>This really hard to say given that the two apps in question were so different.  I would say that ActiveMQ/ActiveMessaging (JMS) will most like perform better given all the code in Java vs. Ruby (perform being separate from scale).  The JMS solution, however, is far more complex and suited for the Enterprise.  Note, this is not to say that Starling can&#8217;t scale. It will just scale differently and with different issues to content with.  If anything, since Starling instances are completely independent, you can scale horizontally almost at will.  That&#8217;s what Twitter does with it, and regardless of what you may think about Twitter, they do scale pretty well.</p>
<p>My experience has been that message flow has never been the issue. It&#8217;s always message processing that is the problem.  My bias will always be towards a solution like Starling because it&#8217;s simpler.  Unless I have a need for absolutely guaranteed message delivery or have huge message backups, I don&#8217;t see a reason to introduce Java, ActiveMQ, and ActiveMessaging to the mix.  I reference huge message backups because Starling is basically a persisted memory queue.  If your queue gets too backed up, you will run out of memory.  JMS has many modes that allow for queue to grow far larger than available memory if necessary.</p>
<p>One more thing, Rails is still not able to handle distributed transactions easily, so the absolute guarantee with ActiveMQ is not happening anyway.  You will need to write additional code to handle failures rather than relying on transactional rollback like you can in Java and other platforms.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil</title>
		<link>http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-262</link>
		<dc:creator>Neil</dc:creator>
		<pubDate>Sat, 25 Oct 2008 07:28:16 +0000</pubDate>
		<guid isPermaLink="false">http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-262</guid>
		<description>Great, maybe it's worth suggesting ActiveMQ &#38; ActiveMessaging support to the play/type guys. 

Based on your experiences with the two (albeit, presumably on different apps  without a fair, scientific, architectural comparison), have you noticed any performance difference between Starling and ActiveMQ/ActiveMessaging?</description>
		<content:encoded><![CDATA[<p>Great, maybe it&#8217;s worth suggesting ActiveMQ &amp; ActiveMessaging support to the play/type guys. </p>
<p>Based on your experiences with the two (albeit, presumably on different apps  without a fair, scientific, architectural comparison), have you noticed any performance difference between Starling and ActiveMQ/ActiveMessaging?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-261</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Fri, 24 Oct 2008 13:51:37 +0000</pubDate>
		<guid isPermaLink="false">http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-261</guid>
		<description>It's unclear to me whether starling would handle transactions properly.  At its core, starling is nothing more than a memcached front end to Ruby's Queue class.  Starling added persistence using a log file, but I'd have to experiment some to see if it properly rolled things back.  Once concern would be rolling the transaction back might affect the log file but not the Queue data.  Also, this would be a distributed transaction across 2-3 processes.  Normally, RoR is not happy about that.

I'm happy with starling for my purposes.  Between its stability, persistence, and the create method (as well as some protective code), I have a system that has a very good chance of not loosing anything.

For other systems I built, the combination of ActiveMQ and ActiveMessaging are a rock. It is not uncommon for those to run for years without any problems.  ActiveMQ is a real queue that supports all forms of transactional integrity.  Using it will require adding new a new client, runner, and poller to workling.  It would be an interesting addition to workling.</description>
		<content:encoded><![CDATA[<p>It&#8217;s unclear to me whether starling would handle transactions properly.  At its core, starling is nothing more than a memcached front end to Ruby&#8217;s Queue class.  Starling added persistence using a log file, but I&#8217;d have to experiment some to see if it properly rolled things back.  Once concern would be rolling the transaction back might affect the log file but not the Queue data.  Also, this would be a distributed transaction across 2-3 processes.  Normally, RoR is not happy about that.</p>
<p>I&#8217;m happy with starling for my purposes.  Between its stability, persistence, and the create method (as well as some protective code), I have a system that has a very good chance of not loosing anything.</p>
<p>For other systems I built, the combination of ActiveMQ and ActiveMessaging are a rock. It is not uncommon for those to run for years without any problems.  ActiveMQ is a real queue that supports all forms of transactional integrity.  Using it will require adding new a new client, runner, and poller to workling.  It would be an interesting addition to workling.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil</title>
		<link>http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-260</link>
		<dc:creator>Neil</dc:creator>
		<pubDate>Fri, 24 Oct 2008 06:58:23 +0000</pubDate>
		<guid isPermaLink="false">http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-260</guid>
		<description>Thanks, Dave, that helps a lot. The intro to ActiveMessaging looks very friendly indeed, I'll book in time to trial it asap. Have you trialled any of them? 

Although, if you're happy with Starling, I'm sure I will for the time being. It's very snappy, at least in comparison to BgRb - and it's up and running in production without any apparent overhead on the production slice (using New Relic Bronze). 

The RSS parsing worker is now on a daemon (see the Railscast on Custom Daemons) - it was going to be called via crontab (and before that it was on a backgroundrb schedule) but this would've loaded the Rails environment every time. Sleeping a daemon avoids that.

Your :create method looks like the post-downtime tidy-up method I was considering, with which any loose items would be picked up and distributed. Feed_items (polymorphic references) have 'feeds' as the has_many_through model (i.e. the reference required for notifying user_id of feed_item_id) and their is validates_uniqueness_of with scope through user_id and feed_item_id - this means we can try distributing the same feed_item twice and only the 'feeds' which weren't sent will be distributed on a second attempt. But, wouldn't it be possible to wrap a transaction block around the worker? Quick research suggests transaction blocks were ripped out of AR and moved to a plugin - still, is that not something we could use with Starling?

Thanks for the insights</description>
		<content:encoded><![CDATA[<p>Thanks, Dave, that helps a lot. The intro to ActiveMessaging looks very friendly indeed, I&#8217;ll book in time to trial it asap. Have you trialled any of them? </p>
<p>Although, if you&#8217;re happy with Starling, I&#8217;m sure I will for the time being. It&#8217;s very snappy, at least in comparison to BgRb - and it&#8217;s up and running in production without any apparent overhead on the production slice (using New Relic Bronze). </p>
<p>The RSS parsing worker is now on a daemon (see the Railscast on Custom Daemons) - it was going to be called via crontab (and before that it was on a backgroundrb schedule) but this would&#8217;ve loaded the Rails environment every time. Sleeping a daemon avoids that.</p>
<p>Your :create method looks like the post-downtime tidy-up method I was considering, with which any loose items would be picked up and distributed. Feed_items (polymorphic references) have &#8216;feeds&#8217; as the has_many_through model (i.e. the reference required for notifying user_id of feed_item_id) and their is validates_uniqueness_of with scope through user_id and feed_item_id - this means we can try distributing the same feed_item twice and only the &#8216;feeds&#8217; which weren&#8217;t sent will be distributed on a second attempt. But, wouldn&#8217;t it be possible to wrap a transaction block around the worker? Quick research suggests transaction blocks were ripped out of AR and moved to a plugin - still, is that not something we could use with Starling?</p>
<p>Thanks for the insights</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-259</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Thu, 23 Oct 2008 12:59:03 +0000</pubDate>
		<guid isPermaLink="false">http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-259</guid>
		<description>If you want true fault tolerance, you could still use workling, but you might want to swap out starling for JMS (ActiveMQ with ActiveMessaging works very well). You would have to write some code in workling to handle the queue.  In a year of hard running, I have never once had starling go down.  The queue is persisted, so even if it did, you would not loose anything in the queue.  However, since there are no transactions, you will loose anything that was in process of being sent or retrieved.

For the Inquisix jobs that have to run, I use a backing database table to keep state of each job.  With that I can add a create method on my worker to restart anything that didn't complete.

For example:

  # Initialize by restarting any jobs that didn't complete
  def create
    jobs = ImportJob.find_in_state(:all, :processing)  # acts_as_state_machine
    jobs.each { &#124;job&#124; ContactWorker.asynch_import_contacts(:job_id =&gt; job.id) }
  end

It's not as safe as JMS, but between the persistence of starling and calling create when started up again, it's pretty close.

Does this help?</description>
		<content:encoded><![CDATA[<p>If you want true fault tolerance, you could still use workling, but you might want to swap out starling for JMS (ActiveMQ with ActiveMessaging works very well). You would have to write some code in workling to handle the queue.  In a year of hard running, I have never once had starling go down.  The queue is persisted, so even if it did, you would not loose anything in the queue.  However, since there are no transactions, you will loose anything that was in process of being sent or retrieved.</p>
<p>For the Inquisix jobs that have to run, I use a backing database table to keep state of each job.  With that I can add a create method on my worker to restart anything that didn&#8217;t complete.</p>
<p>For example:</p>
<p>  # Initialize by restarting any jobs that didn&#8217;t complete<br />
  def create<br />
    jobs = ImportJob.find_in_state(:all, :processing)  # acts_as_state_machine<br />
    jobs.each { |job| ContactWorker.asynch_import_contacts(:job_id => job.id) }<br />
  end</p>
<p>It&#8217;s not as safe as JMS, but between the persistence of starling and calling create when started up again, it&#8217;s pretty close.</p>
<p>Does this help?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil</title>
		<link>http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-258</link>
		<dc:creator>Neil</dc:creator>
		<pubDate>Thu, 23 Oct 2008 10:19:08 +0000</pubDate>
		<guid isPermaLink="false">http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-258</guid>
		<description>Dave, thanks for these posts, they're great - in fact, they're so good, I've subscribed to your blog. 

I've been in the middle of an Engine Yard deployment for a few weeks now - most of the delays have been due to factoring in BackgroundRb (EY use Monit, and they do a whole load of ground work for you regarding deployment recipes etc, BgRb has been causing several issues). So, BackgroundRb is probably just about to be dropped for the two background processes we run; 'feed item' distribution (ala Twitter and Facebook home pages) and RSS parsing, which itself creates one type of 'feed item' for the distribution worker. The feed item distribution is the only candidate for Starling, the RSS worker is just going to drop back to crontab hitting a module.

Just yesterday I swapped over BackgroundRb for Starling/Workling (thanks Railscasts) for the feed item distribution and all seems to be working well in development. I also did tons of reading round on Starling. However, the app can't really afford to lose anything from the queue if something was to go wrong, and this is something I didn't really understand even after lots of reading round. How can Starling be handled with regards to downtime or when the worker code is changed and the process needs restarting? Does the 'feed item' table need to know when feed items have been sent (was thinking along the lines of a 'is_distributed' boolean that would be updated true at the end of the worker transaction, and if things go wrong, I kick up a process to send anything that hasn't been sent) or can we rely on the Starling log to cover this? 

How are you handling potential Starling downtime at Inquisix? Is it still doing the biz? 

p.s. I tried playing with BackgroundJob in place of Starling runner - oddly, it didn't seem to work, although BJ has been working when I use it outside of Workling. Either way, I'm now a big fan of Workling/Starling.</description>
		<content:encoded><![CDATA[<p>Dave, thanks for these posts, they&#8217;re great - in fact, they&#8217;re so good, I&#8217;ve subscribed to your blog. </p>
<p>I&#8217;ve been in the middle of an Engine Yard deployment for a few weeks now - most of the delays have been due to factoring in BackgroundRb (EY use Monit, and they do a whole load of ground work for you regarding deployment recipes etc, BgRb has been causing several issues). So, BackgroundRb is probably just about to be dropped for the two background processes we run; &#8216;feed item&#8217; distribution (ala Twitter and Facebook home pages) and RSS parsing, which itself creates one type of &#8216;feed item&#8217; for the distribution worker. The feed item distribution is the only candidate for Starling, the RSS worker is just going to drop back to crontab hitting a module.</p>
<p>Just yesterday I swapped over BackgroundRb for Starling/Workling (thanks Railscasts) for the feed item distribution and all seems to be working well in development. I also did tons of reading round on Starling. However, the app can&#8217;t really afford to lose anything from the queue if something was to go wrong, and this is something I didn&#8217;t really understand even after lots of reading round. How can Starling be handled with regards to downtime or when the worker code is changed and the process needs restarting? Does the &#8216;feed item&#8217; table need to know when feed items have been sent (was thinking along the lines of a &#8216;is_distributed&#8217; boolean that would be updated true at the end of the worker transaction, and if things go wrong, I kick up a process to send anything that hasn&#8217;t been sent) or can we rely on the Starling log to cover this? </p>
<p>How are you handling potential Starling downtime at Inquisix? Is it still doing the biz? </p>
<p>p.s. I tried playing with BackgroundJob in place of Starling runner - oddly, it didn&#8217;t seem to work, although BJ has been working when I use it outside of Workling. Either way, I&#8217;m now a big fan of Workling/Starling.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-200</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Thu, 05 Jun 2008 11:07:16 +0000</pubDate>
		<guid isPermaLink="false">http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-200</guid>
		<description>I was going to switch because god was leaking memory, but when I upgraded god to 0.7.6, my memory leak went away.  As a result, I stopped investigating making a switch to monit.</description>
		<content:encoded><![CDATA[<p>I was going to switch because god was leaking memory, but when I upgraded god to 0.7.6, my memory leak went away.  As a result, I stopped investigating making a switch to monit.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julien</title>
		<link>http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-199</link>
		<dc:creator>Julien</dc:creator>
		<pubDate>Thu, 05 Jun 2008 05:17:57 +0000</pubDate>
		<guid isPermaLink="false">http://davedupre.com/2008/04/01/ruby-background-tasks-with-starling-part-3/#comment-199</guid>
		<description>I had the same memory problem with god... and I plan to stop using it to switch to monit... 
Have you switched yet? If so, could you please help us with a few hints on the config files to monitor both workling and starling with Monit?</description>
		<content:encoded><![CDATA[<p>I had the same memory problem with god&#8230; and I plan to stop using it to switch to monit&#8230;<br />
Have you switched yet? If so, could you please help us with a few hints on the config files to monitor both workling and starling with Monit?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
