-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use with sinatra and don't block #2
Comments
What does |
@jots just found this and after a quick peek it looks like it's only the IO operations that are run async, á la node.js :). That means that reading the file system, doing database calls etc will allow another fiber to do its work. Would you mind describing what @ioquatix or perhaps I got it wrong? |
@sandelius Even reading from the file system will block the entire reactor. There are trade-offs in the design of such a system and also limitations within Ruby itself. Ideally, we could yield while reading from the file system. In practice, network operations are the highest latency. |
@ioquatix ahh sounds fair |
It's trivial enough to design a thread pool to handle blocking / computational workloads, e.g. https://github.com/socketry/async-process/blob/master/lib/async/process/child.rb |
I'm using falcon with sinatra (
set :server, %w[falcon]
) and trying to get it to handle multiple requests in a non blocking fashion.I have this route:
I test it with:
ab -c 10 -n 10 http://localhost:4567/r/name
I would expect that to take about 1 second, but it takes about 10.
Is there something else I need to do to make it not block?
The text was updated successfully, but these errors were encountered: