# NAS存储上的巨大网络流量

**URL:** https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037
**Category:** Support
**Created:** [2022年十月5日 15:55 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037 "2022-10-05T15:55:52Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [2022年十月5日 15:55 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/1 "2022-10-05T15:55:52Z")

</div>

我正在 NAS 存储 (glusterfs) 上托管我所有的上传文件。

最近我发现 NAS 上有巨大的、持续的网络流量。并追溯到 discourse 请求优化图像。是否有某个任务一直在查找这些图像？为什么？我该如何关闭它？

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [2022年十月5日 23:34 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/2 "2022-10-05T23:34:44Z")

</div>

顺便说一句，我的论坛中已禁用清理上传站点设置。

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2022年十月6日 10:15 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/3 "2022-10-06T10:15:50Z")

</div>

可能是 @david 添加的用于查找主图像颜色的回填。

它最终会完成并恢复到稳定状态。

我们需要遍历回填的所有图像，您可以通过将所有图像的颜色强制设为白色或其他颜色来解决此问题。

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [2022年十月6日 10:43 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/4 "2022-10-06T10:43:36Z")

</div>

> [@sam](#):
>
> 可能是 @david 添加的用于查找主图像颜色的回填。

在我看来，

> <https://github.com/discourse/discourse/blob/d0243f741eaddf6004b7b740b9a2fc948e33cb08/app/jobs/scheduled/periodical_updates.rb#L51>

它每 15 分钟处理 25 张图片。是吗？这应该微不足道。我看到每分钟有数千个文件被查找。

而且，从 6 个月前的带宽来看，我也看到了同样的情况。所以我认为应该是别的原因。

然而，我非常确定这是由 discourse 作业或类似的东西完成的，因为当我停止 discourse 应用程序时，带宽就消失了。但是，当我只停止 discourse nginx 应用程序时，带宽仍然存在。

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2022年十月6日 12:07 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/5 "2022-10-06T12:07:41Z")

</div>

请查看 /sidekiq，它应该会告诉您哪些作业正在运行，请务必点击所有选项卡。

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [2022年十月6日 12:51 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/6 "2022-10-06T12:51:51Z")

</div>

没有作业在运行。 🤔 . 是否还有其他未在此列出的作业？

或者容器中是否有尝试索引文件的东西？

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2022年十月6日 15:03 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/7 "2022-10-06T15:03:11Z")

</div>

我们所有的后台逻辑都在 Sidekiq 作业上运行。如果没有作业在运行，但您仍然有高磁盘 I/O，这可能是用户访问您的网站，并且 nginx 正在提供图片？

您是否有缓存 CDN 来处理静态资源？

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [2022年十月6日 15:08 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/8 "2022-10-06T15:08:01Z")

</div>

> [@Falco](#):
>
> 也许是用户访问您的网站，并且图片由 nginx 提供服务？

我之前测试过。

👇

> [@hnaseri](#):
>
> 当我停止 discourse 应用时，带宽就消失了。但是，当我只停止 discourse 的 nginx 应用时，带宽仍然存在。

所以不是因为用户访问网站。如果是这样，当我停止 nginx 时，流量应该会消失。

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2022年十月6日 15:09 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/9 "2022-10-06T15:09:12Z")

</div>

您需要使用 Linux 检查工具来查看具体正在进行的 PID 和系统调用。

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [2022年十月6日 19:52 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/10 "2022-10-06T19:52:17Z")

</div>

@Falco @sam 我认为我找到了根本原因。

首先，我重启了 discourse 应用，以消除持续的流量。然后我进入了管理面板，并进入了批量报告部分。这里的报告已经很久没有正确显示了：

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/f/8/3f84fd87508b455abf26691151f60b809e8f2f46.png)

报告超时后，我立即看到网络带宽激增。并且我在错误日志中看到了这个错误：

```plaintext
'hijack admin/reports bulk ' 在 db default 上运行了 90 秒后仍然在运行，此进程可能需要重启！

```

这里出了什么问题？

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2022年十月6日 19:54 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/11 "2022-10-06T19:54:04Z")

</div>

数据库是否在同一个NAS存储中？

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [2022年十月6日 19:54 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/12 "2022-10-06T19:54:44Z")

</div>

不，数据库位于物理 SSD 磁盘上。

只有上传文件夹在 NAS 上。

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2022年十月6日 19:55 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/13 "2022-10-06T19:55:16Z")

</div>

因此，两者之间没有相关性。回到

> [@Falco](#):
>
> 您需要使用 Linux 检查工具来确切地查看正在进行的 PID 和系统调用。

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [2022年十月6日 20:00 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/14 "2022-10-06T20:00:58Z")

</div>

> [@Falco](#):
>
> 所以它们之间没有相关性。

事实上，我认为也许存在相关性。在我这里的测试环境中，它计算了已用空间。

 ![image](https://global.discourse-cdn.com/meta/original/4X/b/c/c/bcc97f5ea1c4161c0c7f66ad9feec532c5fd1b81.png)

我认为计算一个有很多文件的 NAS 文件夹的已用空间会非常耗时，并且是高带宽的根本原因。

我说得对吗？ 🤔

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2022年十月6日 22:30 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/15 "2022-10-06T22:30:05Z")

</div>

> [@hnaseri](#):
>
> 我说得对吗？🤔

在网络共享上运行

```plaintext
df -Pk

df -P

du -s

```

是否会花费大量时间？

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [2022年十月6日 22:56 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/16 "2022-10-06T22:56:16Z")

</div>

这两个是即时的

```plaintext
df -Pk

df -P

```

但是 `du -s` 的行为与我上面报告的类似。

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/0/2/c02773a49651fd82b2805f076bbb4c6cc583c7d4.png)

它运行了大约 5 分钟仍未完成，我需要手动终止它。

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2022年十月7日 01:14 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/17 "2022-10-07T01:14:09Z")

</div>

我明白了。该报告结果已缓存，但我想它从未完成，也无法缓存，因为您的网络共享太慢了。

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [2022年十月7日 04:03 UTC](https://meta.discourse.org/t/huge-network-traffic-on-nas-storage/241037/18 "2022-10-07T04:03:15Z")

</div>

有什么办法可以防止这种情况发生吗？例如，将其视为 s3 上传，我们不计算磁盘大小
