# 如何调整大型和重流量站点的参数？

**URL:** https://meta.discourse.org/t/how-to-adjust-parameters-for-large-and-heavy-traffic-site/220696
**Category:** Support
**Created:** [2022年三月11日 02:04 UTC](https://meta.discourse.org/t/how-to-adjust-parameters-for-large-and-heavy-traffic-site/220696 "2022-03-11T02:04:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![topological](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@topological](https://meta.discourse.org/u/topological)
#### Post date: [2022年三月11日 02:04 UTC](https://meta.discourse.org/t/how-to-adjust-parameters-for-large-and-heavy-traffic-site/220696/1 "2022-03-11T02:04:05Z")

</div>

我在一个拥有 38,000 用户、24 核和 64GB 内存的虚拟机上运行社区。我将 `DISCOURSE_UNICORN_WORKERS` 设置为 48。

最近，当 UV 达到 20,000 且 PV 达到 500,000 时，网站响应似乎变慢了。用户会在通知实际发生数小时后才收到通知。

CPU 工作负载约为 15%。所以我认为这是由于 Sidekiq 工作进程太少，并将 `DISCOURSE_UNICORN_SIDEKIQS` 设置为 10，`DISCOURSE_DB_POOL` 设置为 13。但这导致许多页面出现 500 错误。而且我认为这对 PostgreSQL 来说太大了。

所以，我想知道 Discourse 是否会在不手动设置的情况下自动扩展到 24 核服务器？或者如何为像我这样的大型网站设置合适的并发参数？

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [2022年三月11日 11:39 UTC](https://meta.discourse.org/t/how-to-adjust-parameters-for-large-and-heavy-traffic-site/220696/2 "2022-03-11T11:39:40Z")

</div>

> [@topological](#):
>
> Discourse 是否会自动扩展到 24 核服务器而无需手动设置？或者如何为像我这样的大型网站设置合适的并发参数？

我发现最简单的自动扩展资源的方法就是重新运行 `./discourse-setup`，它会用相关参数的新值重新创建 app.yml。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2022年三月11日 11:42 UTC](https://meta.discourse.org/t/how-to-adjust-parameters-for-large-and-heavy-traffic-site/220696/3 "2022-03-11T11:42:01Z")

</div>

关于调整大型网站的几个主题。你可能需要给postgres更多的内存。

---

<div class="post-metadata">

### Author: ![topological](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@topological](https://meta.discourse.org/u/topological)
#### Post date: [2022年三月11日 14:56 UTC](https://meta.discourse.org/t/how-to-adjust-parameters-for-large-and-heavy-traffic-site/220696/4 "2022-03-11T14:56:15Z")

</div>

是的，我尝试修改了 Postgres 中的 `max_connections` 和 `shared_buffers`，并且似乎有效。

---

<div class="post-metadata">

### Author: ![topological](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@topological](https://meta.discourse.org/u/topological)
#### Post date: [2022年三月11日 14:58 UTC](https://meta.discourse.org/t/how-to-adjust-parameters-for-large-and-heavy-traffic-site/220696/5 "2022-03-11T14:58:37Z")

</div>

我可以在 `app.yml` 中看到 `db_shared_buffers` 的更改，但容器内的 Postgres `shared_buffers` 似乎没有改变。

无论如何，我的问题基本解决了。非常感谢。
