単一プロセスの Rack アプリケーションがあるとします。複数の要求が同時に到着した場合、呼び出しはcall(env)
同時に発生しますか? それとも、call(env)
連続して発生することが保証されているため、競合状態はありません@counter
か? Unicorn と Thin の使用に違いはありますか?
require 'json'
class Greeter
def call(env)
req = Rack::Request.new(env)
@counter ||= 0
@counter = @counter + 1
puts @counter
[200, {"Content-Type" => "application/json"}, [{x:"Hello World!"}.to_json]]
end
end
run Greeter.new