Laravel 5.5 redis queue is too slow

人盡茶涼 提交于 2019-12-24 11:01:34

问题


I have dispatch call in action:

dispatch(new ProcessVideo($video));
logger('After dispatch at ' . Carbon::now()->format('H:i:s.u'));

and job:

public function handle() : void
{
    logger('ProcessVideo@handle at ' . Carbon::now()->format('H:i:s.u'));
}

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


回答1:


I face the similar issue as you. There's around 2-3 second delay when processing the first job.

After searching around, I found that laravel queue worker default 3 second sleep.

Which mean the first job will delay 3 second at worse case.

To solve it, just specify --sleep=0 when running the worker. Hope it helps.

php artisan queue:worker --sleep=0


来源:https://stackoverflow.com/questions/46676183/laravel-5-5-redis-queue-is-too-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!