简体   繁体   English

Heroku工人和延迟工作的宝石

[英]heroku workers and delayed job gem

I know there have been a few posts on Heroku and delayed_job but I am still confused on the interaction between Heroku's workers and background jobs. 我知道在Heroku和delay_job上有一些帖子,但是我对Heroku的工人和后台工作之间的互动仍然感到困惑。

So I am launching a new version of my website and I added delayed_job to handle emails. 因此,我启动了我的网站的新版本,并添加了delay_job处理电子邮件。 It says that I just add worker: bundle exec rake jobs:work to my Procfile and I am good to go. 它说我只是将worker: bundle exec rake jobs:work到我的Procfile ,我很高兴。 But wouldn't that mean that the only worker I am paying for is being use for background jobs? 但这不是说我要付钱的唯一工人就是从事后台工作吗? So do I need to get another one then? 那我需要再买一个吗?

Some people also mentioned things like hirefire, which can automatically turn on and off your worker, but that doesn't make perfect sense to me. 有人还提到了例如hirefire之类的事情,它可以自动打开和关闭您的工作人员,但是这对我来说并不是很合理。 Shouldn't that worker always be doing stuff for your website already, so if it is ever in use with delayed_job then it isn't running my website. 那工人不应该一直在为您的网站做事吗,因此,如果将它与delay_job一起使用,那么它就无法运行我的网站。 I have a low level of knowledge on how this all works and would love an explanation. 我对这一切的工作方式了解甚少,不胜感激。

Yeah in order to use delayed_job you need to be paying for one worker process. 是的,要使用delay_job,您需要为一个工作进程付费。 The worker process will only process your delayed_jobs from the queue, and then your normal web process (they give you one for free) will process all of your web requests. 工作进程将仅处理队列中的delay_jobs,然后您的常规Web进程(它们免费为您提供)将处理所有Web请求。 You scale web and worker processes separately. 您分别缩放Web和工作进程。

A heroku ps will show you which processes you have running and you should have at least 1 web and at least 1 worker in order to process web requests and delayed job processes. heroku ps将向您显示正在运行的进程,并且您应该至少具有1个Web和至少1个工作程序,以便处理Web请求和延迟的工作流程。

You can either use the command line or the web interface to add processes, command line to add your worker would be: 您可以使用命令行或Web界面添加进程,添加工作线程的命令行为:

heroku ps:scale worker=1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM