# 加速独立运行 Discourse 的最佳配置

**URL:** <https://meta.discourse.org/t/best-configurations-for-speeding-up-standalone-discourse/162456>\
**Category:** Self-hosting\
**Tags:** server-resources\
**Created:** [2020年八月30日 07:39 UTC](https://meta.discourse.org/t/best-configurations-for-speeding-up-standalone-discourse/162456 "2020-08-30T07:39:37Z")\
**Posts on this page:** 7\
**Page:** 2

<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:** [2020年十月13日 07:49 UTC](https://meta.discourse.org/t/best-configurations-for-speeding-up-standalone-discourse/162456/21 "2020-10-13T07:49:17Z")

</div>

队列机制意味着你可以使用更多的 Web Worker。

此外，你的中位时间看起来相当高，能否在更快的 CPU 上运行？

---

<div class="post-metadata">

**Author:** ![nildarar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nildarar/32/331927_2.png) [@nildarar](https://meta.discourse.org/u/nildarar)\
**Post date:** [2020年十月13日 09:55 UTC](https://meta.discourse.org/t/best-configurations-for-speeding-up-standalone-discourse/162456/22 "2020-10-13T09:55:28Z")

</div>

> [@Jonathan5](#):
>
> “谁在线”插件是导致缓慢的原因

不幸的是，即使缓慢的原因确实是这个插件，我也必须说明，该插件是我们社区的核心插件之一，无论如何都不能将其移除，用户已经严重依赖它！😅

> [@sam](#):
>
> 你能换一台更快的 CPU 吗？

我们目前使用 24 个 Web Worker。我们的 Discourse 安装在一台虚拟机上，该虚拟机配备 24 个 CPU 核心，主频为 2 GHz，内存为 24 GB。不幸的是，除非没有其他提升性能的方法，否则现在无法更换主服务器。

您认为在当前情况下，增加 Web Worker 的数量是否有助于提升性能？

---

<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:** [2020年十月13日 09:58 UTC](https://meta.discourse.org/t/best-configurations-for-speeding-up-standalone-discourse/162456/23 "2020-10-13T09:58:49Z")

</div>

增加更多 Web Worker 可能会减少排队

您正试图从活动 Web 请求图中消除橙色线条

不过，对于典型的中等请求，性能不会有任何提升

---

<div class="post-metadata">

**Author:** ![nildarar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nildarar/32/331927_2.png) [@nildarar](https://meta.discourse.org/u/nildarar)\
**Post date:** [2020年十月13日 10:16 UTC](https://meta.discourse.org/t/best-configurations-for-speeding-up-standalone-discourse/162456/24 "2020-10-13T10:16:00Z")

</div>

谢谢，我现在明白了。通过查看图表，我们可以判断 Web Workers 的数量是否足以满足系统需求。

但根据您的说法，为了提高速度和性能，我们现在需要更强的处理能力，而仅仅调整参数已无法带来更大帮助。

> [@Jonathan5](#):
>
> “谁在线”插件是导致运行缓慢的原因

请务必尽早进行测试，并告知结果。

---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [2022年五月16日 10:36 UTC](https://meta.discourse.org/t/best-configurations-for-speeding-up-standalone-discourse/162456/25 "2022-05-16T10:36:09Z")

</div>

帖子已合并到现有主题：[Telegram Notifications Plugin (discourse-telegram-notifications)](https://meta.discourse.org/t/telegram-notifications-plugin-discourse-telegram-notifications/60483/180)

---

<div class="post-metadata">

**Author:** ![ckshen](https://avatars.discourse-cdn.com/v4/letter/c/ad7895/32.png) [@ckshen](https://meta.discourse.org/u/ckshen)\
**Post date:** [2024年二月14日 18:52 UTC](https://meta.discourse.org/t/best-configurations-for-speeding-up-standalone-discourse/162456/26 "2024-02-14T18:52:52Z")

</div>

> [@RGJ](#):
>
> If you’re not seeing 502’s then there is no use in increasing `UNICORN_WORKERS` either.

502 错误是什么原因？是 unicorn 工作进程不足吗？我们刚迁移了服务器，用户在迁移后偶尔会报告 502 错误。我们有一个 6 核/16GB 的服务器，将 `unicorn_workers` 设置为 16（迁移服务器之前是 12），`db_shared_buffer` 设置为 4GB，`db_work_mem` 设置为 60MB。

过多的 unicorn 工作进程是否会导致 502 错误？（推测，因为在服务器迁移之前我们有 4 个更少的工作进程）

我正在尝试确定是需要调整配置还是需要解决其他问题。

谢谢。

---

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [2024年二月14日 19:27 UTC](https://meta.discourse.org/t/best-configurations-for-speeding-up-standalone-discourse/162456/27 "2024-02-14T19:27:19Z")

</div>

> [@ckshen](#):
>
> 6C/16GB 服务器，并将 `unicorn_workers` 设置为 16

是的，这似乎很高。将您的 unicorn workers 设置在每核 1 到 2 之间。  
对于 6 核，不应超过 12。考虑到您相当大的共享缓冲区和我凭直觉的判断，我会将此设置在 10 左右，以匹配此类服务器规格。

[上一頁](https://meta.discourse.org/t/best-configurations-for-speeding-up-standalone-discourse/162456.md?page=1)
