Laravel 5.5 Redis队列太慢 [英] Laravel 5.5 redis queue is too slow
问题描述
我正在使用调度呼叫:
dispatch(new ProcessVideo($video));
logger('After dispatch at ' . Carbon::now()->format('H:i:s.u'));
和工作:
public function handle() : void
{
logger('ProcessVideo@handle at ' . Carbon::now()->format('H:i:s.u'));
}
在日志中,我们可以看到队列中的分发和处理之间的间隔超过2.5秒!
In logs we can see that interval between dispatch and handling from queue more than 2.5 seconds!
[2017-10-11 00:02:55] local.DEBUG: After dispatch at 00:02:55.423141
[2017-10-11 00:02:58] local.DEBUG: ProcessVideo@handle at 00:02:58.071249
这可能是什么问题?这是我的本地计算机,并且只有一项工作被派遣来测试功能
What the problem can be here? It's my local machine and it's only ONE job which was dispatched to test functionality
推荐答案
我面临与您类似的问题.处理第一份工作大约需要2-3秒的时间.
I face the similar issue as you. There's around 2-3 second delay when processing the first job.
四处搜寻之后,我发现了laravel队列工作者 默认3秒钟睡眠.
After searching around, I found that laravel queue worker default 3 second sleep.
这意味着在较差的情况下,第一份工作会延迟3秒.
Which mean the first job will delay 3 second at worse case.
要解决此问题,只需在运行worker时指定--sleep = 0.希望对您有所帮助.
To solve it, just specify --sleep=0 when running the worker. Hope it helps.
php artisan queue:worker --sleep=0
这篇关于Laravel 5.5 Redis队列太慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!