

The information written to disk will be significantly slower than information kept in RAM, but the operating system will prefer to keep running application data in memory and use swap for the older data.

The swap space on the hard drive will be used mainly when there is no longer sufficient space in RAM to hold in-use application data. This lets you increase the amount of information that your server can keep in its working memory, with some caveats. Swap is a portion of hard drive storage that has been set aside for the operating system to temporarily store data that it can no longer hold in RAM. In this guide, we will cover how to add a swap file to an Ubuntu 20.04 server. One way to guard against out-of-memory errors in applications is to add some swap space to your server.
