User GeorgSeifert reports occasional very high CPU load causing 502 errors on their Discourse forum, despite generally smooth operation. Running on a Hetzner server with 3 vCPUs and 4GB RAM, they captured htop screenshots during spikes but were unsure how to interpret them 5. Community members, notably pfaffman and Ed_S, quickly identified the core issue: no swap space configured. pfaffman explained that even with sufficient RAM, swap is often necessary because processes may consume available memory, leading to resource exhaustion. GeorgSeifert initially believed 4GB (later upgraded to 8GB) was ample, citing Discourse’s claim that 1-2GB RAM suffices — a claim Jagster clarified applies only to minimal setups without plugins or active users. tobiaseigen questioned whether the ./discourse-setup script automatically creates swap, which pfaffman confirmed it does not. GeorgSeifert confirmed no swap was present and asked if the install script could be improved to enable it. merefield provided a link to a tutorial for adding swap on Ubuntu. The consensus is that adding 2GB of swap would likely resolve the issue, allowing the server to handle memory spikes gracefully without requiring excessive physical RAM.
Occasionally I get very high CPU load. Generally the operation is very smooth but then there are those burst of full CPU load. While that is happening, the forum give 502 errors or is VERY slow. I have a Hetzner server with 3 vCPUs and 4 GB of RAM.
If adding swap is the fix, please mark @pfaffman’s post as the solution. It’s the button on the post menu that looks like a square with a checkmark in it.
It is enough — without plugins and few other things, like users and an active admin/moderator. That is absolut minimum and even forum itself can work, rebuilding will fail.
We have here quite few topics about that question and one kind consensus is 2 MB is enought for small forums, if there is swap too.
@pfaffman refresh my memory.. does the ./discourse-setup command not create the swap file automatically?
@GeorgSeifert have you followed the official install instructions to set up your site? If not it is goin to be hard for us to support you here. As everyone is telling you, you need to have a swap file, no matter how much memory you have, otherwise you will run into difficulties.
You often still need swap even with what should be more than enough memory. I think because processes see that more ram is available and they take it and when more RAM is needed it’s not available to other processes.
It does, but only if you have 2GB or less.
He likely did follow the standard install. It’s unclear why he’s running out of ram, but that’s the case. There’s some chance that adding actual RAM will solve the problem.