Laravel Horizon -- 1 Worker processes more than 1 job at a time

1.2k views Asked by At

I have a Laravel Horizon supervisor config that maintains a single process. However, I can't get this process to run only one job at a time. The config for this

'long-running-supervisor' => [
       'connection' => 'redis-long-running',
       'queue' => ['default_long'],
       'balance' => 'simple',
       'processes' => 1,
       'tries' => 1,
       'timeout' => 720
 ],

However this one default_long process overlaps jobs concurrently rather than waiting for one to finish before starting another.

Horizon output (edited for brevity)

WaistPredictionJob 8039
Queue: default_long | Tags: App\Prediction:620  2020-10-17 19:49:45     29.20s  

WaistPredictionJob 8049
Queue: default_long | Tags: App\Prediction:621  2020-10-17 19:50:11     29.08s

PredictionCompleted 8051
Queue: default | Tags: App\Prediction:620   2020-10-17 19:50:16     0.03s

WaistPredictionJob 8054
Queue: default_long | Tags: App\Prediction:622  2020-10-17 19:50:17     25.77s  

PredictionCompleted 8064
Queue: default | Tags: App\Prediction:621   2020-10-17 19:50:46     0.16s

PredictionCompleted 8074
Queue: default | Tags: App\Prediction:622   2020-10-17 19:51:11     0.03s
1

There are 1 answers

0
user2800382 On

I've figured it out.

I was wrongly thinking that the Timestamps were of when the Jobs were completing when in fact they are representing when the jobs were queued.

If you view the timestamps of the PredictionCompleted jobs you'll notice that the WaistPrediciton jobs are in fact running one after another.