在 Heroku 上设置 Puma 工人数
Setting Number of Puma Workers on Heroku
如果我在 Heroku 配置中设置了 WEB_CONCURRENCY=3,为什么会有 4 个 Puma worker?
在中了解到New Relic调用Puma工人"app instances"。
这是我的 puma.rb
配置:
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 1)
threads threads_count, threads_count
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
# Valid on Rails 4.1+ using the `config/database.yml` method of setting `pool` size
ActiveRecord::Base.establish_connection
end
Heroku 配置:
WEB_CONCURRENCY: 3
Puma 有一个主进程。
它不处理请求。它监视和管理(重启或其他)工作人员。
如果设置3个并发,则有4个进程。 3 个工人(管理请求)和 1 个主程序(管理工人)
如果我在 Heroku 配置中设置了 WEB_CONCURRENCY=3,为什么会有 4 个 Puma worker?
在
这是我的 puma.rb
配置:
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 1)
threads threads_count, threads_count
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
# Valid on Rails 4.1+ using the `config/database.yml` method of setting `pool` size
ActiveRecord::Base.establish_connection
end
Heroku 配置:
WEB_CONCURRENCY: 3
Puma 有一个主进程。
它不处理请求。它监视和管理(重启或其他)工作人员。
如果设置3个并发,则有4个进程。 3 个工人(管理请求)和 1 个主程序(管理工人)