Rails,Heroku,Unicorn& Resque - 如何选择网络工作者/ resque工作者的数量? [英] Rails, Heroku, Unicorn & Resque - how to choose the amount of web workers / resque workers?
问题描述
我不明白从这是如何config / unicorn.rb:
worker_processes 3
超时30
@resque_pid = nil
before_fork | server,worker |
@resque_pid || = spawn(bundle exec rake+ \
resque:work QUEUES = scrape,geocode,distance,mailer)
end
$
$ b
$ b 实际上在每个网络测试中会产生六个过程:1个独角兽主人,3个独角兽网络工作者,1个重新工作者,1个重新启动的童工,当它实际上正在处理一项工作时
有多少员工会实际处理后台工作? 1或2?
可以说我想增加resque workers的数量 - 我会改变什么?
解决方案我想如果你运行这个块,你的麒麟master已经在运行,再加上你在文件顶部指定的3个web worker,然后下面的块会启动一个Resque worker如果它还没有开始。
我猜Resque在实际执行工作时会自行启动一个子工作者。
$ b $如果你想要另一个Resque worker,你可以这样做:
worker_processes 3
timeout 30
@resque_pid = nil
@ resque_pid2 = nil
before_fork do | server,worker |
@resque_pid || = spawn(bundle exec rake+ \
resque:work QUEUES = scrape,geocode,distance,mailer)
@ resque_pid2 || = spawn( bundle exec rake+ \
resque:work QUEUES = scrape,geocode,distance,mailer)
end
根据我对Resque的经验,就像启动上面指定的另一个过程一样简单。我所遇到的唯一不确定因素是Heroku以及它如何选择处理给你更多的工人。
I've just switched to using Unicorn on Heroku. I'm also going to switch to resque from delayed_job and use the setup described at http://bugsplat.info/2011-11-27-concurrency-on-heroku-cedar.html
What I don't understand from this is how config/unicorn.rb:
worker_processes 3
timeout 30
@resque_pid = nil
before_fork do |server, worker|
@resque_pid ||= spawn("bundle exec rake " + \
"resque:work QUEUES=scrape,geocode,distance,mailer")
end
translates into:
"This will actually result in six processes in each web dyno: 1 unicorn master, 3 unicorn web workers, 1 resque worker, 1 resque child worker when it actually is processing a job"
How many workers will actually process background jobs? 1 or 2?
Lets say I wanted to increase the number of resque workers - what would I change?
解决方案 I think if you run that block, you have your unicorn master already running, plus 3 web workers that you specify at the top of the file, and then the block below launches one Resque worker if it's not already started.
I'm guessing that Resque launches a child worker by itself when it actually performs work.
It would appear that if you wanted another Resque worker, you could just do
worker_processes 3
timeout 30
@resque_pid = nil
@resque_pid2 = nil
before_fork do |server, worker|
@resque_pid ||= spawn("bundle exec rake " + \
"resque:work QUEUES=scrape,geocode,distance,mailer")
@resque_pid2 ||= spawn("bundle exec rake " + \
"resque:work QUEUES=scrape,geocode,distance,mailer")
end
In my experience with Resque, it's as simple as launching another process as specified above. The only uncertainty I have is with Heroku and how it chooses to deal with giving you more workers.
这篇关于Rails,Heroku,Unicorn& Resque - 如何选择网络工作者/ resque工作者的数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!