gpt4 book ai didi

Laravel horizo​​n 排队时间长

转载 作者:行者123 更新时间:2023-12-05 05:02:19 26 4
gpt4 key购买 nike

我在 Laravel Horizo​​n 中遇到排队时间问题..

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

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

这是我的地平线配置:

Horizon configuration

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

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

Email screenshot

有人可以帮我解决这个问题吗?提前致谢..

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

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

  • 我在 horizo​​n config 中分配了 100k 最大进程(我昨天甚至将其更改为 1.000.000 最大进程)

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

  • 如何使队列处理更快?是否有我遗漏的地平线/服务器配置?一些限制配置可能在 PHP 限制/Redis 限制/任何限制?

最佳答案

以下方法来自地平线库

/**
* 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 秒可能是一个指示。

关于Laravel horizo​​n 排队时间长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62257964/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com