Jeff Atwood wrote:
Most cloud virtual machine providers do not set up swapfiles as part of their server provisioning.
If you are running the recommended 2 GB of memory for Discourse, a swap file is technically not required, but can be helpful just in case your server experiences memory pressure. With a swap file, rather than randomly terminating processes with an out of memory error, things will slow down instead.
This can be done at any time from the command line on your server.
Set up a 1 GB swap file
Adding a swap file gives Discourse some extra beathing room during memory-intensive operations. 1GB swap should suffice, though if you are attempting the minimum memory configuration you should set up a 2GB swap.
In the shell you have opened to your droplet, do the following:
write out a 1 GB file named 'swapfile'
dd if=/dev/zero of=/swapfile bs=1024 count=1024k
tell linux this is the swap file:
mkswap /swapfile
Activate it
swapon /swapfile
Add it to the file system table so its there after reboot
open fstab in nano
nano /etc/fstab
paste the following line in at the bottom
/swapfile none swap sw 0 0
Set the swappiness to 10 so its only uses as an emergency buffer
echo 10 | sudo tee /proc/sys/vm/swappiness echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
Change the permissions so only root can read and write to this file
chown root:root /swapfile chmod 0600 /swapfile
Posts: 10
Participants: 4