简体   繁体   English

Laravel Horizo​​n 限制总进程数

[英]Laravel Horizon limit the amount of total processes

After reading quite some posts ( Like this one from Zechariah Campbell ) about Laravel Horizon with a Redis Queue and trying to configure it and customize it I couldn't find out if it's possible to maximize the total amount of processes run by laravel horizon.在阅读了很多关于 Laravel Horizo​​n 和 Redis 队列的文章( 比如来自 Zechariah Campbell 的这篇文章)并尝试对其进行配置和自定义之后,我不知道是否可以最大化 laravel 地平线运行的进程总数。

Using the strategy "simple" and having one process per Queue (which is what I want) might cause cpu or internal memory issues when having like 1000 queues which will cause 1000 processes to run?使用“简单”策略并且每个队列有一个进程(这是我想要的)可能会导致 cpu 或内部内存问题,当有 1000 个队列会导致 1000 个进程运行时? (Every Queue gets their own process by default) (默认每个队列都有自己的进程)

Is there any way to maximize the total amount of processes spawned by horizon, regardless of the amount of queues?无论队列数量如何,有没有办法最大化地平线产生的进程总数? So 10 processen en 20 queues and when one queue is empty or even better one job of one queue was processed, the worker will pick another queue?所以 10 个处理 20 个队列,当一个队列是空的或者更好的是处理了一个队列的一项工作时,工作人员会选择另一个队列吗?

My current configuration我现在的配置

horizon.php地平线.php

'local' => [
            'supervisor-1' => [
                'connection' => 'redis',
                'balance'    => 'simple',
                'processes'  => 1,
                'tries'      => 2,
            ],
        ],

queue.php队列.php

'redis' => [
            'driver'      => 'redis',
            'connection'  => 'queue',
            'queue'       => "1000,2000,3000",
            'retry_after' => 90,
            'block_for'   => null,
        ],

laravel 5.8 and horizon 3.0 Laravel 5.8 和地平线 3.0

currently I use beanstalkd but want to migrate to redis queue with horizon because of the lack of maintainance of beanstalkd and some nasty bugs.目前我使用 beanstalkd,但由于缺乏 beanstalkd 的维护和一些讨厌的错误,我想迁移到地平线的 redis 队列。

UPDATE 2019-05-17:更新 2019-05-17:

I tried the config maxProcesses:我尝试了配置 maxProcesses:

'local' => [
            'supervisor-1' => [
                'connection' => 'redis',
                'balance'    => 'simple',
                'maxProcesses' => 1,
                'processes'  => 1,
                'tries'      => 2,
            ],
        ],

But even then three processes are created, one for each queue.但即便如此,也会创建三个进程,每个队列一个。 在此处输入图片说明

As of Horizon 4 (and previous versions), it will always assign at least 1 worker to each queue.从 Horizo​​n 4(和之前的版本)开始,它始终会为每个队列分配至少 1 个工作线程。 There's no way around it.没有办法解决。 So, if your minProcess is 1 but you have 3 queues then you'll have at least 3 processes (workers).因此,如果您的minProcess为 1 但您有 3 个队列,那么您将至少有 3 个进程(工人)。 I guess the minProcess setting is more of a minProcessPerQueue thing.我猜minProcess设置更像是minProcessPerQueue事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM