如果我在Heroku配置中设置WEB_CONCURRENCY = 3,为什么我有4名Puma工作人员?
在this question中,我了解到New Relic称Puma工作者" app实例"。
这是我的import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib import colorbar
from matplotlib.colors import Normalize
import numpy as np
def plotcb(vals, plims, cax):
vmin, vmax = np.percentile(vals, plims)
cmap = cm.get_cmap('plasma')
cmap.set_bad('w', 1.)
cmap_scalar = cm.ScalarMappable(norm=Normalize(vmin, vmax), cmap=cmap)
cmap_scalar.set_array(np.ma.array(vals, mask=np.isnan(vals)))
cb = colorbar.Colorbar(cax, cmap_scalar)
return cmap_scalar.to_rgba(vals)
f, cax = plt.subplots()
all_values = np.linspace(0,1,100)
print plotcb(all_values, [0, 50], cax)
plt.show()
配置:
puma.rb
Heroku配置:
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
答案 0 :(得分:3)
Puma有一个主过程 它不处理请求。它监视和管理(重启或某事)工人。
如果设置3并发,则有4个进程。 3名工人(管理要求)和1名主要工作人员(管理工人)