I have a controller function which dispatchs a job. When this job is handled, at the end it dispatch the same job again (with different args). There are 5 jobs of the same in total.
Queue driver: database
The problem is: I record the time duration from create() to handle(). The first job dispatched by the controller took 1700ms, where the other jobs dispatched by the jobs themselves took only 40ms.
Queue driver: sync
When I changed to use sync queue driver, all the jobs worked in lightning speed.
Findings:
The first queue job took long time from create() to handle(). Before that the queue was empty. It might be the queue driver problem.
Why and how to fix please? thanks!!
UPDATE:
Added a TestJob that dispatch itself when job was handled. That meant the queue always had a TestJob being handled or waiting for handling.
Repeating my original jobs, they all took only <70ms from created() to handle() completed.
Conclusion:
I am pretty sure it is the queue driver problem. Looks like the worker fall asleep when the queue is empty. Do anyone know the fix please?