My discourse installation has been getting slower and slower and slower over the last few weeks. In the past when this has happened, rebuilding the app has helped. However, it doesn’t seem to help now.
I’ve looked for advice on this forum, and tried some database optimizations (vacuum full verbose, rebuild index, vacuum analyze verbose)
However, none of it seems to help, and when I start the container, it takes a really really long time before I can actually connect to the forum.
If this keeps up, the forum will eventually become completely unusable. Any idea where to start looking?
That vmstat output is telling us that - as things are - there’s not enough RAM.
It could be that Discourse is working as it should, and all is as it should be, but that your data has grown to the point that 4G of RAM is not enough.
Or it could be that something has gone wrong and a lot of RAM is in use which should not be in use.
One measure of size is to take a backup-without-attachments and see how big that is.
It might be that the mini-profiler will give a clue as to what database actions are taking so long.
If you have the budget to double the RAM, do that. (If you take care to increase the RAM but leave the storage as-is, if you have such an option from your provider, then this can be a reversible and even a temporary change.)
If you can’t afford more RAM, you can try setting lower values for db_shared_buffers (say 128MB or lower) and limiting UNICORN_WORKERS to just 2 in the meanwhile, as you need to stop swapping ASAP.
More RAM is fairly pricey from my hosting provider, so I will explore other options first. (And I’m worried that changing it will break my grandfathered-in pricing…)
I changed db_shared_buffers to 128Mb and UNICORN_WORKERS to 2.
Is launcher app stop / start enough to make these settings take effect?
With an Alt+P on your keyboard, subsequent forum actions should put up a timing string just under the forum banner (for me, on the right) and if you click on the timing, you’ll see a popup window with some stats.
That’s about the same as mine, running with 1G of RAM. I have 2k topics, 15k posts, 500+ signups.
What’s the history of your Discourse? I dimly recall a time in the past when one was supposed to create an index for some table for performance reasons.
What about plugins? Can you run actions in safe mode to see if they run any quicker?
On the /about page, there’s a column for all-time.
Looks like your machine hasn’t been rebooted for well over a year - probably worth doing that, and updating for security at the same time. It’s just possible the reboot will help.
I think I notice that your server is setup to use hypervisor whereas mine is setup to use lxc. I don’t know if that’s important. (My system shows a process /usr/bin/lxcfs which yours doesn’t, and yours shows a process hv_vss_daemon which mine doesn’t.)
Also, maybe you could share output of df -T and swapon.
I agree with a skeptical attitude on this! But I don’t suggest it idly - I’m fairly sure we’ve seen a case of a long-running system which did improve with a reboot. (Edit: here, although it was a different case.)