有没有人在Heroku Dyno中运行过一个以上的复古工人? [英] Does anyone run more than one resque worker in a Heroku Dyno?
问题描述
p>
到目前为止,任何人都可以成功完成这项任务吗?我的想法是,一个简单的方法可以让Procfile运行工头,然后运行2个(或更多)实际工人实例(即 rake resque:work
)
或者是 rake resque:workers
直至该任务? Resque本身并不建议使用该方法,因为这会在并行线程中而不是在并行进程中启动worker。
显然,这仅适用于I / O绑定作业。
可以使用领班启动多个进程。将工头添加到您的Gemfile中,然后创建两个文件:
$ b Procfile :
worker:bundle exec foreman start -f Procfile.workers
Procfile.workers :
worker_1:QUEUE = * bundle exec rake resque:work
worker_2:QUEUE = * bundle exec rake resque:work
同样的技术可以用来运行网页服务器以及一些工人。
注意:虽然许多州采用这种方法取得成功,但我不会建议在一些实验之外使用它,主要是因为存在风险遇到小型heroku实例的RAM限制;一旦你支付了heroku服务,无论如何只需要启动一个专门的工人机器就可以了。
Given that unicorn usually manages more than one Rails server process, and given that a Resque job runner probably consumes less resources than a Web request, it should be possible to run more than one resque worker on a single Heroku dyno.
Is anyone doing this successfully so far? My thoughts are, that an easy way to do so would have the Procfile runs foreman, which then runs 2 (or more) instances of the actual worker (i.e. rake resque:work
)
Or is rake resque:workers
up to that task? Resque itself does not recommend using that method, as this starts workers in parallel threads instead of in parallel processes.
Obviously, this makes sense only on i/o bound jobs.
One can use foreman to start multiple processes. Add foreman to your Gemfile, and then create two files:
Procfile:
worker: bundle exec foreman start -f Procfile.workers
Procfile.workers:
worker_1: QUEUE=* bundle exec rake resque:work
worker_2: QUEUE=* bundle exec rake resque:work
The same technique can be used to run a web server alongside some workers.
NOTE: while many state success using this approach, I would not suggest to use it outside of some experiments, mostly because of the risk to run into RAM limitations on small heroku instances; and once you pay for the heroku service it is probably easier to just spin up a dedicated worker machine anyways.
这篇关于有没有人在Heroku Dyno中运行过一个以上的复古工人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!