Martin Svoboda Martin Svoboda - 1 month ago 10
Ruby Question

Clustered puma not accepting more than 1 request concurrently

I have setup my puma web server based on heroku manual: Deploying Rails Applications with the Puma Web Server

config/puma.rb
:

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 2)
threads threads_count, threads_count

preload_app!

rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
ActiveRecord::Base.establish_connection
end


Procfile
contains:

web: bundle exec puma -C config/puma.rb


Now when I try to access action which has
sleep 10
which delays the response and then try to access some other action, my understanding was that Puma would handle these 2 requests concurrently (since I have 2 workers). But instead it waits for the first request which sleeps to finish then it proceeds to the second one. Am i missing something?

My setup is:


  • Ruby 2.2.4

  • Rails 4.2.0



EDIT:

Ok, so I found out that on Heroku, it works, so question is, why it doesn't work in development mode?

Answer

rails s does not use the Procfile, you may want to look at using a tool like foreman: https://github.com/ddollar/foreman

update: this was the solution:

config.allow_concurrency = true in the rails development config.