Most cloud virtual machine providers do not set up swapfiles as part of their server provisioning.
In particular, upgrading Discourse produces a lot of memory pressure. With a swap file, rather than randomly terminating processes with an out of memory error, things will slow down instead. Having a swap file is a cheap insurance policy that protects you from many other load related failures.
This can be done at any time from the command line on your server.
Set up a 2GB swap file
We recommend a 2GB swap file for Discourse, unless your server has 4GB or more of memory.
In the shell you have opened to your droplet, do the following:
Create an empty swapfile
sudo install -o root -g root -m 0600 /dev/null /swapfile
write out a 2GB file named ‘swapfile’
dd if=/dev/zero of=/swapfile bs=1k count=2048k
tell linux this is the swap file:
Add it to the file system table so its there after reboot:
echo "/swapfile swap swap auto 0 0" | sudo tee -a /etc/fstab
Set the swappiness to 10 so its only uses as an emergency buffer
sudo sysctl -w vm.swappiness=10 echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
The whole thing as a single copy and pastable script:
sudo install -o root -g root -m 0600 /dev/null /swapfile dd if=/dev/zero of=/swapfile bs=1k count=2048k mkswap /swapfile swapon /swapfile echo "/swapfile swap swap auto 0 0" | sudo tee -a /etc/fstab sudo sysctl -w vm.swappiness=10 echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf