Skip to content

Instantly share code, notes, and snippets.

@costis
Last active November 4, 2018 15:17
Show Gist options
  • Save costis/3848ac003746b28ae5a6e314c0bf7642 to your computer and use it in GitHub Desktop.
Save costis/3848ac003746b28ae5a6e314c0bf7642 to your computer and use it in GitHub Desktop.
# Do a `gem install rack` first
#
# Running with `puma -t 1` we see the request blocking.
# Running with `puma` there is no blocking (default is `-t 16`)
#
# Maybe filler is not thread safe and we have a rece condition somewhere.
# If this is the case, running `puma -t 1 -w 10` should work fine (10 processes, 1 thread for process).
require "rack"
app = Rack::Builder.app do
map '/fast' do
run Proc.new { |env|
puts "Executing fast path"
['200', {'Content-Type' => 'text/plain'}, ["I am fast!\n"]]
}
end
map '/slow' do
run Proc.new { |env|
puts "Executing slow path"
sleep(20) # blocking call
['200', {'Content-Type' => 'text/plain'}, ["I am slow!\n"]]
}
end
end
run app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment