问题
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