Skip to content
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

all requests on a single thread #23

Closed
yob opened this issue Dec 19, 2011 · 2 comments
Closed

all requests on a single thread #23

yob opened this issue Dec 19, 2011 · 2 comments

Comments

@yob
Copy link

yob commented Dec 19, 2011

I've just tried puma on a rails 3.1.1 app. I added 'config.threadsafe!' to 'config/environments/production.rb' and get the following output when I boot the app:

⚡ RAILS_ENV=production bundle exec puma --threads 0:3
Puma 0.9.1 starting...
* Min threads: 0, max threads: 3
* Listening on tcp://0.0.0.0:9292
Use Ctrl-C to stop

I then created a controller action that looks like this:

def index
    product.connection.select_all("select sleep(10)")
    render :text => "I should have taken 10 seconds! (id: #{Thread.current.object_id})"
end

If I make 2 concurrent requests they seem to execute serially and the thread ID is identical. Am I missing something?

@evanphx
Copy link
Member

evanphx commented Dec 19, 2011

That's odd. Could you replace the 2nd line with just "sleep 10" and see what happens?

Perhaps
a) you're on MRI 1.8 or 1.9 and
b) the database adapter you're using uses a C extension (likely) and
c) the C extension doesn't release the GVL nor does it use rb_thread_select (likely)

@yob
Copy link
Author

yob commented Dec 19, 2011

my bad, my testing methodology was flawed. Testing with ab shows the expected results.

On MRI 1.9.3 both:

sleep(n)

and (with mysql2):

Product.connection.select_all("select sleep(#{n})")

result in fully concurrent requests. Thanks!

@yob yob closed this as completed Dec 19, 2011
aleksei-burlakov pushed a commit to aleksei-burlakov/puma that referenced this issue Sep 6, 2022
Add the existing monitor interests to the exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants