Should I increase the swap file from 2GB?

I recently installed Discourse again, but in Hetzner servers. Now I have 4GB of RAM and 40GB of space. By default it created the 2GB swap file

image

Is that enough?

לייק 1

Watch it using htop during a build. Probably enough.

3 לייקים

Which Linux distro did you use for the install on the servers?

I would have recommended using a swapfile instead of a swap partition.

Swapfiles are the default nowadays on most distros and are more flexible in terms of adjusting the swappiness.

I don’t believe a swap partition was mentioned?

I think 2GB swap + 4GB RAM is enough. I don’t think you’d need more swap unless you’re running other stuff on your server as well.

My apologies, you are correct.

Should have made sure to drink more coffee before replying :wink:

It depends how much there in plugins in use, AI etc. For me 4+2 wasn’t enough.

לייק 1

I’m not an expert so I just took some screenshot along the way:

SCR-20251221-ilhi

SCR-20251221-imkv

This was right after it completed:

SCR-20251221-imvf

Then, I let it run for a little bit longer, because I was seeing the 0 and 1 bars (I’ assuming those are the cores?) both hitting around 80% and I wanted to see if that was just temporary:

SCR-20251221-ince

SCR-20251221-infh

SCR-20251221-inoo

SCR-20251221-inzv

Does this help?

For the most part, the Mem was no higher than maybe 500M, average. During the rebuild the highest it went was maybe 1GB or so, but very briefly. Only after the rebuild stopped did it go to those values of 1.6GB or so.

And even now, after it stopped for a few minutes, I’m still seeing this, so I wonder if that’s normal?

image

@NateDhaliwal and @Rubi I didn’t do anything myself, it created it automatically, so I’m assuming it’s swapfile? I just followed the official instructions to install and let it do its thing. Hope that clarifies?

@Jagster I don’t have a lot of stuff. No AI, at least not that I installed anything myself, and other than the native plugins, I only have 3 that I installed, along with Components, which are probably 20 or less, but I don’t think those are that relevant?

Yep, it is a swapfile. IIRC a change was made earlier this year to create a swapfile if under 5GB RAM (I think it used to be 1 GB?).

לייק 1

Clearly enough, plenty of spare capacity, you are good to go :+1:

לייק 1

I might give this a go myself next time. Do you just open a separate terminal window and type htop? Any recommended options? I’ll do an internet search for more general information about it.

Yes. But note this is not a fine tool. It’s obvious here 2GB is enough but If you want a more accurate peak of swap use you might investigate sysstat and logging. I’ll leave you to research that.

2 לייקים

Awesome! Thank you for your feedback and for the htop command, which I wasn’t aware of. Saved it to my notes.

2 לייקים

For myself, I’d not use htop but instead vmstat 5 because that leaves a clear text log of what it saw (every 5 seconds). That’s handy because you can scroll back, or search for the worst moment. The worst moment is what matters, really, especially if it causes failure. The average situation (during a rebuild) isn’t informative. With a tool like htop you could easily miss seeing the peak, and once it’s past you can’t review.

I’ve posted before about vmstat and explained how to interpret the output.

2 לייקים