Create a swapfile for your Linux server


(Jay Pfaffman) #52

Do you have swap on already?

free will show you swap.


(Jesse Perry) #53

Anyone have any advice on if I need a swapfile if my server has 4GB of memory? If so, what should the size be?


(cpradio) #54

You are not required to. If you wanted to play it safe, a 1 GB file should be more than sufficient and rarely used.


(Tumi) #57

Hello ,

There is any sense to create 3 GB , 4GB SWAP for instance with 1 GB RAM . Any profits here ?(1% more better work is a profit )


(cpradio) #58

You are better off investing in more physical RAM than a larger SWAP file.


(Stephen Chung) #59

Obviously you can create a swapfile any size you want. If it is not needed, it will just sit there merrily holding zeros. The disk space will simply be wasted.

So the trick is to size your swap large enough for the heaviest operation, which in Discourse should be the rebuild. Check memory usage on a rebuild to see how much is needed.

I think there are studies out there saying that very large swap files will not be useful because the CPU is gonna start thrashing way before that much swap is used.

EDIT: Searching on the net, it is recommended the swap to be no larger than 2 times physical RAM due to declining returns of adding more.


(Jay Pfaffman) #60

./discourse-setup will now create the swap file, so there is (usually) no reason to do it yourself. If you have a too-small swapfile you should delete it before running discourse-setup.