c10k paradigm [SOLVED]

Alexandre Riveira alexandre at objectdata.com.br
Tue Apr 16 20:27:18 UTC 2013


Tanks for all helpers. Erick, this solutions CheckDefered is pefect !And 
run in production !

1) rack middleware
class CheckDeferred

   def initialize(app)
     @app = app
   end

   def call(env)
     @app.call(env)
   end

   def deferred?(env)
     case env["PATH_INFO"]
       when /\/ecommer.*/
         false
       else
         true # erp run by thread
     end
   end
end


2) edit your config.ru
require File.expand_path "config/environment"

use CheckDeferred #first if not function
use Rails::Rack::LogTailer
use Rails::Rack::Static
run ActionController::Dispatcher.new


Alexandre Riveira



Em 16-04-2013 20:48, Eric Wong escreveu:
> Alexandre Riveira <alexandre at objectdata.com.br> wrote:
>> Em 16-04-2013 18:35, Eric Wong escreveu:
>>> See what Mark just said.  Also, t/app_deferred.ru in the rainbows
>>> source[1].  There's also a link to Ezra's old post about it in the
>>> TryDefer documentation.
>>>
>>> [1] - git clone git://bogomips.org/rainbows && $EDITOR t/app_deferred.ru
>> In file ems/rainbows-4.5.0/lib/rainbows/event_machine.rb line 74:
>> server.app.respond_to?(:deferred?)
>> server.app is a Rails::Rack::LogTailer class.
>>
>> should not be ActionController::Dispatcher.new or like ???
> You should probably write a new middleware around/outside of your
> normal Rack layer.  Something like this:
>
> class CheckDeferred < Struct.new(:app)
>    def deferred?(env)
>      case env["PATH_INFO"]
>      when %r{/manager/},
>           %r{/foo/bar},
> 	 ... # whatever other paths you want multithreaded
>        true
>      else
>        false
>      end
>    end
> end
>
> ----------- config.ru --------------
> use CheckDeferred # needs to be the outermost layer of middleware
>
> use ...
> run Application.new
> ------------------------------------
> _______________________________________________
> Rainbows! mailing list - rainbows-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rainbows-talk
> Do not quote signatures (like this one) or top post when replying
>



More information about the rainbows-talk mailing list