3

我在 Laravel Horizo​​n 的排队时间有问题..

案例:我有一个考试监考软件,每 30 秒从约 1500 名学生的网络摄像头拍摄照片。然后我把它放在队列中,通过 websocket 向老师广播最新的图像。

我的服务器有 32 个 CPU 和 192GB RAM。

这是我的地平线配置:

地平线配置

我从系统中收到了一些类似的电子邮件。像这样从 1000 秒到 >30k 秒不等。

即使我放了 100k maxProcesses,队列处理也感觉很慢。

电子邮件截图

有人可以帮我弄这个吗?提前致谢..

编辑:为了使问题更清楚,这里是摘要:

  • 我的服务器有 32 个 CPU 和 192GB RAM (Ubuntu 18.04)。

  • 我在 Horizo​​n 配置中分配了 10 万个最大进程(我昨天什至将其更改为 1.000.000 个最大进程)

  • 但是队列处理没有我想象的那么快。其中一个队列甚至有 30k+ 秒的等待时间。

  • 如何让队列处理更快?我错过了任何地平线/服务器配置吗?一些限制配置可能在 PHP 限制/Redis 限制/任何限制中?

4

1 回答 1

2

以下方法来自地平线存储库

/**
 * Handle the event.
 *
 * @param  \Laravel\Horizon\Events\SupervisorLooped  $event
 * @return void
 */
public function handle(SupervisorLooped $event)
{
    if (! $this->dueToMonitor()) {
        return;
    }

    // Here we will calculate the wait time in seconds for each of the queues that
    // the application is working. Then, we will filter the results to find the
    // queues with the longest wait times and raise events for each of these.
    $results = app(WaitTimeCalculator::class)->calculate();

    $long = collect($results)->filter(function ($wait, $queue) {
        return $wait > (config("horizon.waits.{$queue}") ?? 60);
    });

    // Once we have determined which queues have long wait times we will raise the
    // events for each of the queues. We'll need to separate the connection and
    // queue names into their own strings before we will fire off the events.
    $long->each(function ($wait, $queue) {
        [$connection, $queue] = explode(':', $queue, 2);

        event(new LongWaitDetected($connection, $queue, $wait));
    });
}

LongWaitDetected事件触发电子邮件。“31941 秒”是您webcam队列的等待时间。每当supervisor开始循环时,它就会触发MonitorWaitTimes并且上面的代码有效。

如果您不想收到这封电子邮件,请将您的队列名称添加到waits阵列中的地平线配置中,并带有大量数字。

'waits' => [
    'redis:default' => 60,
    'redis:webcam' => 1514124141
],

但请记住;这可能表明某些流程/作业无法正常工作。30K 秒可能是一个指示。

于 2020-06-08T13:07:39.033 回答