By default Google Compute Engine (Debian) doesn’t come with any swap space. If you have periodic programs that eat a bit more memory (like my backups do) then instead on just adding more physical memory you can add a swap file.
Swaps files are much slower than physical memory, so should be avoided except when it is needed.
Setting up a swap file on Debian on Google Compute Engine is described here
sudo fallocate -l 2G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile sudo swapon -s
To make this permanent add this to /etc/fstab
/swapfile none swap sw 0 0
If you need to resize the swap file
sudo swapoff /swapfile sudo fallocate -l 4G /swapfile sudo mkswap /swapfile sudo swapon /swapfile
How much swap? Well that is down to your system. Maybe start with 1x your physical memory and then run memory diagnostics tools.
Leave a Reply