Looking at different web stacks (ruby mostly), and seeing if/how they work in parallel.
run Plel.new
Two requests take one second. Apparrently Rack will process requests in parallel. How does rack do this?
paral.rb
require 'sinatra/base'
class Paral < Sinatra::Base get '/' do sleep 1 "Hi" end end
Same result for a sinatra app in rack. Two requests, one second.
went back to the simplest of all webservers, straight webrick
class Paral < WEBrick::HTTPServlet::AbstractServlet
def do_GET(request, response) status, content_type, body = do_stuff_with(request)
response.status = status
response['Content-Type'] = content_type
response.body = body
end
def do_stuff_with(request) sleep 1 return 200, "text/plain", "Hello World" end
end
server = WEBrick::HTTPServer.new({:Port=>8081}) server.mount "/", Paral server.start
Still just one second. Whats going on with this?