[英]Delayed Job workers not running in parallel
(Re-added due to remove sensitive information) (由于删除了敏感信息而重新添加)
We currently have 4 delayed job workers processing background jobs created by our main application. 当前,我们有4名延迟的工作人员在处理由我们的主应用程序创建的后台工作。 These are all spawned with their own instance via an upstart script. 这些都是通过新贵脚本使用自己的实例生成的。 We would expect these 4 workers to work concurrently however they are now waiting on each other to complete before another job is processed. 我们希望这4个工人可以同时工作,但是他们现在彼此等待完成另一个工作。 This is causing huge backlogs in our job pool as in essence only 1 job is being run at once rather than the desired 4. 这实际上在我们的工作池中造成大量积压,因为实际上一次只能运行1个作业,而不是所需的4个作业。
Things I have tried but to no avail: 我尝试过但无济于事的事情:
script/delayed_job start
& bundle exec rake jobs:work
) 使用两种语法生成script/delayed_job start
工人( script/delayed_job start
和bundle exec rake jobs:work
) Is there something that we're missing here? 我们这里缺少什么吗? How can we get the workers running in parallel again? 我们如何才能使工人再次并行运行? Thanks in advance. 提前致谢。
Upstart Script (this is run 4 times with a different index): Upstart脚本(使用不同的索引运行4次):
instance $index
script
# this script runs in /bin/sh by default
# respawn as bash so we can source in rvm
exec /bin/bash <<'EOT'
# rvm
source /home/user/.rvm/scripts/rvm
cd /home/foo/bar/current
exec /usr/bin/env RAILS_ENV=production bundle exec rake jobs:work
EOT
end script
Open to correction on the following statements - I recently learned and implemented delayed_jobs on AWS. 可以纠正以下语句-我最近在AWS上学习并实现了delay_jobs。
In PROD I am using bin/delayed_job and daemons gem as per https://github.com/collectiveidea/delayed_job 在PROD中,我按照https://github.com/collectiveidea/delayed_job使用bin / delayed_job和daemons gem
My app is on AWS so the start/restart command is: 我的应用程序在AWS上,因此start / restart命令为:
su -s /bin/bash -c "bundle exec bin/delayed_job -n 2 --pid-dir=$EB_APP_PIDS_DIR restart" $EB_APP_USER
rake jobs:work is usually used to start the workers in development environment from various articles I read. rake jobs:工作通常用于从我阅读的各种文章中引导开发环境中的工人。
To troubleshoot the problem further, try doing this in rails console: 要进一步解决问题,请尝试在Rails控制台中执行以下操作:
Delayed::Worker.new
and check if the jobs get processed faster. 并检查作业是否得到更快处理。
Another thing to try: Stop all workers via whatever script you normally use. 要尝试的另一件事:通过通常使用的脚本停止所有工作程序。 Then do 然后做
ps -ef | grep "jobs:work"
to see if the all the worker processes actually get killed. 查看所有工作进程是否真的被杀死。 If the worker system processes are still hanging around, you have to manually kill those system processes. 如果辅助系统进程仍然存在,则必须手动终止这些系统进程。 Then restart the workers and check if any difference in behavior. 然后重新启动工作程序,并检查行为是否有差异。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.