Different horizon configs based on server

48 views Asked by At

In config/horizon.php you can define how many processes you want to dedicate to each Horizon queue. If I have a second server that isn't used for processing requests, and is just going to be used to process certain jobs and tasks, how can I set it so that ONLY this second server looks at one queue and the other main server doesn't look at that queue?

Eg I have a queue called Webhooks, and I want the second server to process Webhooks only and the main server not to process any jobs from the Webhooks queue at all. What's the right way to go about that?

Do I just have a different horizon.php file on each server, one with 0 processes assigned to Webhooks and one with, say, 20 processes assigned?

1

There are 1 answers

1
Marcin Orlowski On BEST ANSWER

Yes, you can have different config file on each server as you described but that might be painful to maintain in some cases. As alternative solution you can have single, shared config but then delegate certain parameters that differ to env vars, so set in each server's . env file.

'environments' => [
    'production' => [
        'Webhooks' => [
            'queue' => ['webhooks'],
            'balance' => 'simple',
            'processes' => env('WEBHOOKS_PROCESS_COUNT', 0),
            'tries' => 3,
        ],
        ... 
    ],
],

Then, in the .env file of your main server, you can set:

WEBHOOKS_PROCESS_COUNT=0

And on the second server:

WEBHOOKS_PROCESS_COUNT=20