ClementN's avatar

Queue system, Horizon supervisor clarification

Hello,

Please help me to avoid some confusions regarding the queues system and Horizon

Question 1)

Is the "supervisor-1" term from the Laravel Horizon docs referring to the same thing as the "Supervisor" from the Laravel Queue docs?

Ref: https://laravel.com/docs/8.x/horizon#supervisors vs https://laravel.com/docs/8.x/queues#supervisor-configuration

Question 2)

If I start Horizon using php artisan horizon do I still need to run php artisan queue:work ?

Ref: https://laravel.com/docs/8.x/horizon#running-horizon vs https://laravel.com/docs/8.x/queues#running-the-queue-worker

Thank you for your time,

0 likes
2 replies
Tippin's avatar
Tippin
Best Answer
Level 13

@clementn For question 1, they are not the same. However, in regards to question 2, you will not have to run queue:work anymore, however you will want to setup a supervisor on the server itself to keep the php artisan horizon process running, which was documented here: https://laravel.com/docs/8.x/queues#installing-supervisor

As for what the supervisors are in regarding question 1, you may want to choose to allot a different number of processes/workers per supervisor to more fine tune your queue system, or say you want different tries/balance/etc defined per supervisor. One thing to preface, you must define a supervisor config for each environment you use, or you may find it not running on one! As an example, I use 2 supervisors in my production for this demo, giving two supervisors 10 processes each, and they watch over different queues.

    'environments' => [

        'production' => [
            'supervisor-1' => [
                'connection' => 'redis',
                'queue' => ['pushNotify', 'messenger'],
                'balance' => 'simple',
                'minProcesses' => 1,
                'maxProcesses' => 10,
                'processes' => 10,
                'tries' => 2,
            ],
            'supervisor-2' => [
                'connection' => 'redis',
                'queue' => ['notifications', 'emails', 'default'],
                'balance' => 'simple',
                'minProcesses' => 1,
                'maxProcesses' => 10,
                'processes' => 10,
                'tries' => 3,
            ],
        ],

        'staging' => [
            'supervisor-1' => [
                'connection' => 'redis',
                'queue' => ['pushNotify', 'messenger'],
                'balance' => 'simple',
                'minProcesses' => 1,
                'maxProcesses' => 10,
                'processes' => 5,
                'tries' => 2,
            ],
            'supervisor-2' => [
                'connection' => 'redis',
                'queue' => ['notifications', 'emails', 'default'],
                'balance' => 'simple',
                'minProcesses' => 1,
                'maxProcesses' => 10,
                'processes' => 3,
                'tries' => 3,
            ],
        ],

        'local' => [
            'supervisor-1' => [
                'connection' => 'redis',
                'queue' => ['pushNotify', 'messenger', 'default', 'notifications', 'emails'],
                'balance' => 'simple',
                'minProcesses' => 1,
                'maxProcesses' => 10,
                'processes' => 3,
                'tries' => 1,
            ],
        ],
    ],
1 like

Please or to participate in this conversation.