如何解决网站加载速度过慢的问题?

我一直在花很长时间优化我的 CSS,移除插件,移除重定向,尽我所能提高加载速度,但显然主要问题出在:

mobile_4-randomcharacters-.css,其中包含 normalize.css 和 Pikaday,在移动端的加载时间为 1.5 秒
以及 /assets/ember_jquery-randomcharacter-.js,在移动端的加载时间为 3.6 秒

我对这些加载时间最长的文件束手无策,不知道该如何处理。

桌面端的加载速度较快,但也不理想。
服务器配置为:1 核 CPU、2 GB 内存、50 GB SSD、2 TB 带宽,位于美国的专业服务器上。
运行 2 个 Unicorn 工作进程,CPU 和内存均未处于高负载状态,且用户数量和插件数量都不多。
有什么建议吗?谢谢。

测量工具:https://developers.google.com/speed/pagespeed/insights/

Those are static assets, and to optimize delivery of those you should Enable a CDN for your Discourse

thank you, PageSpeed Insights says the CPU time (not delivery time) specifically for the second asset was almost 4 seconds, will a CDN like fastly still help with that? I currently use cloudflare with caching, is there a tweak on cloudflare I should use or just add something like fastly on top?!

That is indeed a big asset that will take time to parse and evaluate. As Discourse is a “Single Page Application” that cost is all paid upfront when the user first arrive, and this is a trade-off of our the approach, which is focused on making all the subsequent interaction, typical of forum usage, lightweight.

There are plan for EmberJS to drop mandatory JQuery, which will reduce this payload a fair bit, but we are years away of making this transition in Discourse.

thanks for the response, I think something must be off with my configuration, as i have never heard anyone else reporting those load times

Well, the pagespeed defaults force a Nexus 5X and a 3G connection, which even for Brazil (a third world country) is on the low end for today standards, so real world performance will depend on that.

您好,我刚刚在 Hetzner 服务器(CPX21,3 核 vCPU,4GB 内存)上完成了一次全新的 Discourse 安装。参考的指南是:discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub

服务器性能统计中几乎没有任何负载显示,但 URL 加载却耗时极长。在无痕窗口中,非登录访客的加载时间竟长达 1.2 分钟,即使许多组件已在缓存中。最慢的是 OpenSans ttf 字体文件,耗时超过一分钟;随后多个 .js 组件也花费了 30 到 45 秒。

我会研究缓存选项,但查看这些组件后,我认为并非所有都能被缓存。总数据传输量仅为 730KB。如果 3 个 vCPU 都在满负荷运行,我会考虑升级到更快的服务器,但鉴于负载显示几乎为零,我感到非常困惑。

是否有某个环节在等待其他资源完成才能继续?有没有办法在服务器上运行测试以检查数据库等组件的健康状况?Docker 是否可能导致了性能变慢?

我也遇到了同样的问题,
在 Ubuntu 上全新安装,拥有 2 个核心、4GB 内存和 Cloudflare 缓存,但加载速度仍然非常慢。

我的 app.yml 设置是默认的,即 db_shared_buffers: "1024MB" UNICORN_WORKERS: 4

加载速度仍然很慢,这不正常。我需要调整哪些设置来解决这个问题?

Htop ss 似乎不是服务器问题

也许值得分享一些来自 mini-profiler 的统计数据

也许还可以阅读一下
Discourse 安装速度越来越慢