class SleepHandler < Mongrel::HttpHandler
def process(request, response)
response.start do |head,out|
head["Content-Type"] = "text/html"
sleep 300 # Long running task
out.write("test") # Push out the result
end
end
end
#Handler configs
config = Mongrel::Configurator.new :host => ARGV[0], :port => ARGV[1] do
listener(:num_processors => 80, :timeout => 400) do
uri "/sleep", :handler => SleepHandler.new
uri "/nosleep", :handler => NoSleepHandler.new
end
trap("INT") { stop }
run
end
puts "Mongrel running on #{ARGV[0]}:#{ARGV[1]} with docroot #{ARGV[2]}"
config.join
I stressed this mongrel handler with 50 concurrent requests and everything came back in 5 min and 45 secs and maximum memory comsumption was 32MB so in my view decent performance by mongrel.
No comments:
Post a Comment