← ServerPilot Docs

Swap Is Enabled

ServerPilot enables 512 MB of swap space on your server.

If your server already had swap space enabled when you connected it to ServerPilot, then no additional swap space is added.

What Is Swap Space?

Swap space is fake memory that is actually disk space.

The purpose of swap space is to be emergency overflow memory. Normally, if your server runs out of memory, the Linux kernel has to decide which processes to kill to free up memory. Often it's MySQL that gets killed first.

When you have swap space enabled and your server runs out of memory, the kernel can use swap space instead of killing processes to free memory. This means a temporary spike in memory usage won't crash your database or websites.

Viewing Your Swap Usage

You can view your swap space usage by running this command as the root user:

free -m

This example shows 125 MB of swap space used by the server.

The swap space shown by running free -m does not mean your server is actively swapping at the moment; remember swap space is only used when your server runs out of memory. This number can be cleared by rebooting your server.

Swap Space Is Slow

Swap has a big downside: it's slow.

Even if your server has an SSD disk (like those at DigitalOcean), it's still extremely slow compared to RAM. At best, SSD-backed swap is 1000x slower than memory.

In fact, even when using SSD-backed swap, your server can sometimes become so slow that your websites are inaccessible or your visitors leave before pages load.

So, if you care about performance, don't rely on swap space. Instead, use a server with enough memory to handle your peak memory usage and keep your swap space for emergencies.

Last updated: August 30, 2017

Launch your first site in 5 minutes