简体   繁体   English

Laravel 5.7 - 队列作业太慢

[英]Laravel 5.7 - Queues Jobs are too slow

I use Laravel 5.7 and 3 queues jobs, the time between jobs is too long/slow.我使用 Laravel 5.7 和 3 个队列作业,作业之间的时间太长/太慢。

I foreach items of RSS feeds in the first job, and I dispatch this item in second job, etc... I don't enter in details but there are some ridiculous little calculations that must not take time.我在第一份工作中 foreach RSS 提要项目,我在第二份工作中发送这个项目,等等......我没有详细输入,但有一些荒谬的小计算,不能花时间。

The problem is that every dispatch to a job takes a lot of time.问题是每次派遣工作都需要花费大量时间。 Horizon and Telescope do not allow me to debug. Horizo​​n 和 Telescope 不允许我调试。

The machine I use has 32 GB of RAM, and there are several processes (15 each) that turn the tails.我使用的机器有 32 GB 的 RAM,并且有几个进程(每个 15 个)可以扭转局面。

[program:mywebsite_feeder]
command=/RunCloud/Packages/php72rc/bin/php artisan queue:work redis --queue=feeder --tries=3 --sleep=0
directory=/home/runcloud/webapps/mywebsite
redirect_stderr=true
autostart=true
autorestart=true
user=runcloud
numprocs=15
process_name=%(program_name)s_%(process_num)s

I have this error in laravel.log:我在 laravel.log 中有这个错误:

production.ERROR: App\\Jobs\\FeederJob has been attempted too many times or run too long. production.ERROR: App\\Jobs\\FeederJob 尝试次数过多或运行时间过长。 The job may have previously timed out.该作业之前可能已超时。

by default laravel queues sleep 3 seconds when there are no jobs available.默认情况下,当没有可用作业时,laravel 队列会休眠 3 秒。 u should use --sleep=0 option你应该使用--sleep=0选项

I had the same issue and did a lot of searches but nothing help, even there is some issues about this bug in horizon Github but without a useful solution.我遇到了同样的问题并进行了大量搜索,但没有任何帮助,即使地平线 Github 中存在有关此错误的一些问题,但没有有用的解决方案。 the problem is about horizon and Redis bug for heavy tasks.问题是关于地平线和重任务的 Redis 错误。

finally, I switch from Redis and horizon to SQL database (whatever you use in your project for me mssql) as queue connection and it fixed the problem最后,我从 Redis 和地平线切换到 SQL 数据库(无论你在我的项目中使用什么 mssql)作为队列连接,它解决了问题

notice: use --timeout=0 in your artisan command注意:在您的工匠命令中使用--timeout=0

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

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