From e8eb252f64c94eb57532ef3de55d28e5d23e3cd8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 4 Oct 2009 20:17:58 -0700 Subject: vary defaults for worker_connections Various concurrency models work and scale differently, pick counts that make a reasonable amount of sense... --- lib/rainbows.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lib/rainbows.rb') diff --git a/lib/rainbows.rb b/lib/rainbows.rb index b2c315d..04be9b4 100644 --- a/lib/rainbows.rb +++ b/lib/rainbows.rb @@ -13,14 +13,23 @@ module Rainbows require 'rainbows/http_response' require 'rainbows/base' - autoload :Revactor, 'rainbows/revactor' - autoload :ThreadPool, 'rainbows/thread_pool' - autoload :ThreadSpawn, 'rainbows/thread_spawn' - class << self def run(app, options = {}) HttpServer.new(app, options).start.join end end + # maps models to default worker counts, default worker count numbers are + # pretty arbitrary and tuning them to your application and hardware is + # highly recommended + MODEL_WORKER_CONNECTIONS = { + :Base => 1, # this one can't change + :Revactor => 50, + :ThreadSpawn => 30, + :ThreadPool => 10, + }.each do |model, _| + u = model.to_s.gsub(/([a-z0-9])([A-Z0-9])/) { "#{$1}_#{$2.downcase!}" } + autoload model, "rainbows/#{u.downcase!}" + end + end -- cgit v1.2.3-24-ge0c7