In Linux, when physical memory (RAM) is full, inactive pages in memory are moved to the swap. Swap space is located on hard drive, which is significantly slower than RAM. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. However, it’s very useful when you need a little bit more RAM for a brief piece of time, like compiling software etc.
Many VPS providers (like Digital Ocean) don’t enable swap automatically, and you need to enable it by yourself. Here’s how: