Swapping is the process of moving data from a system’s memory (RAM) to a preconfigured space on the hard drive, known as the
swap space. Enabling swap, in many cases, is an easy and cheap way to squeeze a little more from a server. The most beneficial feature of swap is that it allows your system to use more memory resources than you have physical RAM.
A perfect example of how this is helpful comes from real life. The other day I decided to revisit the ownCloud project to see how it had matured since I last tried it. For my test platform I spun up a small DigtialOcean Droplet with 512mb of RAM. During my initial syncing of files MySQL kept exhausting all of the RAM, crashing, and bringing the whole ownCloud service to its knees. Even after tweaking MySQL the problem still persisted. Then it dawned on me that, like most virtual machines, DigitalOcean Droplets don’t have swap enabled by default. So, instead of adding more physical ram (ie: costing more money) I enabled swap, and the problem went away.