Swap is disk space the server can use when its RAM is full. It prevents out-of-memory crashes, but is much slower than RAM.
sudo fallocate -l 2G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab free -h
A swap file of 1–2× your RAM (up to a few GB) is enough for most servers. If your server uses swap all the time, it needs more RAM – consider upgrading your VPS or moving to a dedicated server.