Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

an option to split queues for auto balancing #1502

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions config/horizon.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,20 @@

'memory_limit' => 64,

/*
|--------------------------------------------------------------------------
| Process Per Queue
|--------------------------------------------------------------------------
|
| This option allows you to execute separate processes for every
| supervisor's queue if the balancing strategy is "auto".
| Disabling it will stop splitting queues so the worker will
| will handle many queues
|
*/

'process_per_queue' => true,

/*
|--------------------------------------------------------------------------
| Queue Worker Configuration
Expand Down
4 changes: 2 additions & 2 deletions src/Repositories/RedisWorkloadRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public function get()

$splitQueues = Str::contains($queue, ',') ? $length->map(function ($length, $queueName) use ($connection, $totalProcesses, &$wait) {
return [
'name' => $queueName,
'name' => "$queueName",
'length' => $length,
'wait' => $wait += $this->waitTime->calculateTimeToClear($connection, $queueName, $totalProcesses),
'wait' => $wait += $this->waitTime->calculateTimeToClear($connection, "$queueName", $totalProcesses),
];
}) : null;

Expand Down
2 changes: 1 addition & 1 deletion src/Supervisor.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function __construct(SupervisorOptions $options)
*/
public function createProcessPools()
{
return $this->options->balancing()
return $this->options->balancing() && config('horizon.process_per_queue', true)
? $this->createProcessPoolPerQueue()
: $this->createSingleProcessPool();
}
Expand Down