I just installed Discourse, but the pages load very slowly due to slow external database

Homepage take up 2-4 sec to respond

Started GET "/" for 219.144.218.209 at 2025-03-17 18:22:55 +0000

Processing by ListController#latest as HTML

Rendered layout layouts/application.html.erb (Duration: 1932.6ms | GC: 10.6ms)

Completed 200 OK in 2521ms (Views: 1933.4ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 14.9ms)

My server has 2 CPU cores and 8GB of RAM.

The log shows layouts/application.html.erb rendered so slow.

I removed some content in layouts/application.html.erb and it take up to 300-500ms to respond.

<discourse-assets>
    <discourse-assets-stylesheets>
      <%= render partial: "common/discourse_stylesheet" %>
    </discourse-assets-stylesheets>
    <discourse-assets-json>
      <div class="hidden" id="data-preloaded" data-preloaded="<%= preloaded_json %>"></div>
    </discourse-assets-json>
    <discourse-assets-icons></discourse-assets-icons>
  </discourse-assets>

Each user request consumes a large amount of CPU.
Please help me.

Did you do a standard install?

2 Likes

Yes, i did.

And i found issue yesterday.

I used a remote database, The layout component of discourse fetch 60+sqls, every sql need ±30ms to transfer,so the first render cause 2-4 sec.

The issue go away when I changed to local database.

1 Like

Yes, it does: