群集的puma不同时接受超过1个请求

时间:2016-08-06 21:04:31

标签: ruby-on-rails ruby puma mri

我已根据heroku手册设置了我的puma网络服务器: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包含:

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

现在,当我尝试访问具有sleep 10延迟响应然后尝试访问其他操作的操作时,我的理解是Puma将同时处理这两个请求(因为我有2个工作者)。但相反,它等待第一个睡眠完成的请求然后进入第二个请求。我错过了什么吗?

我的设置是:

  • Ruby 2.2.4

  • Rails 4.2.0

修改

好的,所以我发现在Heroku上,它有效,所以问题是,为什么它在开发模式下不起作用?

1 个答案:

答案 0 :(得分:2)

rails s不使用Procfile,您可能希望使用像foreman这样的工具:https://github.com/ddollar/foreman

更新:这是解决方案:

rails开发配置中的

config.allow_concurrency = true