有没有人在Heroku Dyno中运行过一个以上的复古工人? [英] Does anyone run more than one resque worker in a Heroku Dyno?

查看:182
本文介绍了有没有人在Heroku Dyno中运行过一个以上的复古工人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于独角兽通常管理多个Rails服务器进程,并且考虑到Resque作业运行器可能比Web请求消耗更少的资源,应该可以在单个Heroku dyno上运行多个resque worker。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆