c10k paradigm

Mark J. Titorenko mark at titorenko.net
Tue Apr 16 18:19:22 UTC 2013

On 16 Apr 2013, at 18:24, Eric Wong <normalperson at yhbt.net> wrote:
> Did you modify your app to use app.deferred? + TryDefer as I pointed
> you to in the other message?
>> Could it be that  the controllers  of the  rails  would run without
>> party  pool  threads  only with  EventMachine  (C10K) while others
>> would use the  controller  with  EventMachine thread pool  (erp)?
> That should allow some rails controllers to use threads
> (app.deferred? => true) while others do not use threads
> (app.deferred? => false).  Keep in mind this is not a very common
> configuration, so not many people have experience with it in
> production.

In case it's of any use I am using #deferred? and TryDefer in my Rails app.  I have it set up such that all controller requests are deferred (ie. use threads) apart from those which are, by their nature, asynchronous - eg. I am using Faye mounted at '/ext/bayeux' within my application which already uses the [-1, {}, []] technique to provide an async response.  I have #deferred set up by including a module in my Rails::Application instance.

In application.rb:

module App::Application < Rails::Application
  require 'extensions/deferred_application'
  include Extensions::DeferredApplication

In lib/extensions/deferred_application.rb:

module Extensions
  module DeferredApplication
    BAYEUX_REGEX = %r(^/ext/bayeux(/.*)?$).freeze

    def deferred?(env)
      !(env['REQUEST_PATH'] =~ BAYEUX_REGEX)




More information about the rainbows-talk mailing list