<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Brainspl.at: Deferred requests with merb, ebb and thin</title>
    <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Brainspl.at</description>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by Ben Schwarz</title>
      <description>@Ezra 
What if I have dynamic urls or permalinks? Perhaps the deferred action setting could be implemented much like the cache_actions method for a controller. 
That way the the deferred call would be pretty transparent.. </description>
      <pubDate>Tue, 13 May 2008 09:40:48 +0000</pubDate>
      <guid>urn:uuid:7cd3634e-8657-4c5f-8ce3-69faaeb56eaa</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4821</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by Ezra</title>
      <description>@Bob- good point, if you wrap your app in any middleware you are on your own with this one. But perhaps we could add a deferred? method to the middleware that recursively checks defined? on any middleware wrapped apps and returns if any of them say yes?</description>
      <pubDate>Tue, 29 Apr 2008 06:23:08 +0000</pubDate>
      <guid>urn:uuid:c8461d80-a32c-4f3a-93f8-545011afbf16</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4796</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by Bob Aman</title>
      <description>Ok, so what about Rack middleware?

If you wrap your app in any of the Rack middleware classes, thin/ebb interface with the middleware rather than the app itself.  Because the deferred? method isn't part of the official Rack API, thin/ebb don't relay the deferred? method (they don't define a deferred? method at all) and the method on your app never gets called.

Aside from monkey-patching and avoiding Rack middleware entirely, what options are there?
</description>
      <pubDate>Mon, 28 Apr 2008 17:46:58 +0000</pubDate>
      <guid>urn:uuid:925453b8-d185-417f-9cdb-da46c5ec1491</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4795</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by R. Elliott Mason</title>
      <description>Noice.</description>
      <pubDate>Thu, 24 Apr 2008 18:17:03 +0000</pubDate>
      <guid>urn:uuid:5cf945fb-fb88-493a-8f05-45c7f3f6a153</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4759</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by Ezra</title>
      <description>@Todd -  you are correct in that during the transfer of data from the client to the server it does not block the event loop. But when your app needs to parse the multi part request body and then do whatever other file processing your action does that will definitely block the event loop if you don't spin off your own thread.</description>
      <pubDate>Wed, 23 Apr 2008 00:37:01 +0000</pubDate>
      <guid>urn:uuid:9c8db0f6-b48b-4475-b596-234c8fa4e78a</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4758</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by Todd</title>
      <description>Seems like something is wrong here... event loop should be faster...  event handlers for file upload are all writes and reads right?  Unless something else is going on during the file upload, it should be able to stay mostly in kernel space during the upload - freeing the event loop to accept more incoming requests... At any rate this seems really good for long requests that are doing a lot of user space processing...
</description>
      <pubDate>Tue, 22 Apr 2008 22:44:14 +0000</pubDate>
      <guid>urn:uuid:e3b034d5-421e-42d1-b3d7-8fd514047fa7</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4757</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by Justin Pease</title>
      <description>Sounds very cool.  Look forward to actually trying it out.</description>
      <pubDate>Sat, 19 Apr 2008 21:54:11 +0000</pubDate>
      <guid>urn:uuid:001dadf5-f733-4a45-a766-c2a43926bb8c</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4756</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by Aníbal Rojas</title>
      <description>I like pretty much the idea, the problem with this approach is too many "slow" request being serviced, generating too many threads for the system resources to handle, memory, cpu. Or am I missing something in the picture?</description>
      <pubDate>Sat, 19 Apr 2008 10:43:04 +0000</pubDate>
      <guid>urn:uuid:eff7c8a3-816b-43c7-b653-63a03d4923b8</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4755</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by ry</title>
      <description>sweet. ebb 0.2 with support for this be coming this weekend too</description>
      <pubDate>Fri, 18 Apr 2008 20:29:34 +0000</pubDate>
      <guid>urn:uuid:1c846c37-de53-4b8d-842c-d26e8a5f512e</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4754</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by Daniel Fischer</title>
      <description>Very cool that they, and you added support for this. Rock on.</description>
      <pubDate>Fri, 18 Apr 2008 19:13:02 +0000</pubDate>
      <guid>urn:uuid:e22db14d-087d-492d-8164-6218b87e0b5e</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4753</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by Tim Dysinger</title>
      <description>Woops.  Now that I look again it was yesterday.  http://github.com/wycats/merb-core/commit/289e65e5d35814f7bfc2ca91d01782b2e66eb5fa</description>
      <pubDate>Fri, 18 Apr 2008 18:31:15 +0000</pubDate>
      <guid>urn:uuid:31de2b52-a418-49b2-b608-3df80a923ad1</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4752</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by Tim Dysinger</title>
      <description>I saw the commit on github a couple days ago.  Cool stuff Ezra.</description>
      <pubDate>Fri, 18 Apr 2008 18:25:45 +0000</pubDate>
      <guid>urn:uuid:9feab60f-c253-4cc5-984b-6ced0237e6b2</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4751</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by nap</title>
      <description>Scratch that. the *RUBY* web app deployment space, that is.</description>
      <pubDate>Fri, 18 Apr 2008 14:52:08 +0000</pubDate>
      <guid>urn:uuid:527a908c-6ffd-4fd5-9653-1f5a387fec50</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4750</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by nap</title>
      <description>Nice. This is great news. The Rails deployment space is getting very interesting lately.</description>
      <pubDate>Fri, 18 Apr 2008 14:51:53 +0000</pubDate>
      <guid>urn:uuid:d21857de-75e0-4000-9905-597ba8a956b2</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4749</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by macournoyer</title>
      <description>Awesome!

New gem version of Thin including this change should be out this weekend.</description>
      <pubDate>Fri, 18 Apr 2008 13:58:43 +0000</pubDate>
      <guid>urn:uuid:7ea73c81-8e59-4aeb-b3c4-7b725fdedf1a</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4748</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by Doug</title>
      <description>Very cool. Thanks, Ezra, and thanks to the Ebb and Thin developers.</description>
      <pubDate>Fri, 18 Apr 2008 12:41:41 +0000</pubDate>
      <guid>urn:uuid:7ca0b6b8-5da2-41ac-aa22-ddf86f0923b2</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4747</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by Ed Spencer</title>
      <description>Awesome stuff, we've got an app with some long reports which could take advantage of that - not using Merb though sadly... any idea if this is/will be possible with Rails?</description>
      <pubDate>Fri, 18 Apr 2008 10:46:28 +0000</pubDate>
      <guid>urn:uuid:d994bf41-3a9c-4b39-88cd-44f7a5fdf9ac</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4746</link>
    </item>
    <item>
      <title>"Deferred requests with merb, ebb and thin" by Yaroslav</title>
      <description>This *rules*. Thanks!</description>
      <pubDate>Fri, 18 Apr 2008 07:55:18 +0000</pubDate>
      <guid>urn:uuid:1002142d-7b95-4446-80eb-cb133bb390b8</guid>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin#comment-4745</link>
    </item>
    <item>
      <title>Deferred requests with merb, ebb and thin</title>
      <description>&lt;p&gt;There is a classic tradeoff between threaded servers and event driven servers. Event driven servers tend to be much faster than threaded servers when all the requests are fairly fast. But the event model falls down if you have long requests like file uploads or reporting actions. This is because the long action blocks the event loop, effectively keeping other requests from running.&lt;/p&gt;


	&lt;p&gt;There are two new event driven ruby webservers at your disposal these days, &lt;a href='http://code.macournoyer.com/thin/'&gt;Thin&lt;/a&gt; and &lt;a href='http://ebb.rubyforge.org/'&gt;Ebb&lt;/a&gt;. Both of these servers support the &lt;a href="http://rack.rubyforge.org/"&gt;Rack&lt;/a&gt; web server interface that merb uses. Until now both of these servers were not the  best choice for file uploads or long blocking actions but that&amp;#8217;s all changing.&lt;/p&gt;


	&lt;p&gt;Both ebb and thin have added a  deferred?(env) method to their rack adapter interface. Both webservers will call this method on your Rack @app object before they call your call(env) method. This allows your rack adapter to determine if the request  should be run in its own thread if it&amp;#8217;s slow.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ve just committed support for this deferred_actions construct in merb-core. If you want to run on thin or ebb but you have say a file upload action and some slow reporting actions you could add this to your init.rb in your app:&lt;/p&gt;


&lt;pre&gt;
Merb::Config[:deferred_actions] = ["/uploads/create", "/reports/longaction"]
&lt;/pre&gt;

	&lt;p&gt;What this means is that all of your actions will run in fast event driven mode except for requests to /uploads/create and /reports/longaction. Any request for either of these urls will be served from a newly spawned thread, all other requests will be served by the main event loop.&lt;/p&gt;


	&lt;p&gt;This allows us to have the best of both world. Combining threaded and event driven styles to use the strengths of both makes a lot of sense here.&lt;/p&gt;


	&lt;p&gt;Cheers to the authors of ebb and thin for making the same interface. All of this requires the &lt;span class="caps"&gt;HEAD&lt;/span&gt; versions of ebb or thin so if you want to play along at home you will need to build thin or ebb from source on github: &lt;a href='http://github.com/ry/ebb/tree/master'&gt;ebb&lt;/a&gt;  and  &lt;a href='http://github.com/macournoyer/thin/tree/master'&gt;thin&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 18 Apr 2008 06:20:00 +0000</pubDate>
      <guid>urn:uuid:5abcc2ca-5cd0-4b02-8e6f-20ed23ec7d62</guid>
      <author>ezmobius</author>
      <link>http://www.brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin</link>
      <category>ebb</category>
      <category>thin</category>
      <category>deferred</category>
      <trackback:ping>http://www.brainspl.at/articles/trackback/4744</trackback:ping>
    </item>
  </channel>
</rss>

