
Swap is disk space the system uses as spare memory when the RAM fills up. It does not make the server faster: it exists so that, in a peak, the system slows down instead of killing processes. Many new VPS come with no swap at all, which is why the database or the site “vanish” suddenly: the system ran out of memory and chose the biggest program to shut down (see out of memory on a VPS: what the OOM killer is). The commands are yours, on your own server: support does not run them for you (see how far our support goes).
First, see whether you have any
Run free -h and swapon --show. If the “Swap” line of the first shows zero and the second prints nothing, there is no swap. On a KVM server like our VPS, swap is yours to configure.
Creating a swap file
|
|
|
|
|
Tuning and undoing
| I want to… | Command |
| See how readily the system uses swap | cat /proc/sys/vm/swappiness (the lower, the later it uses it) |
| Lower the value until the next reboot | sudo sysctl vm.swappiness=10 |
| Switch swap off | sudo swapoff /swapfile, remove the line from /etc/fstab and delete with sudo rm /swapfile |
| Swap is not real memory. A disk is far slower than RAM: if the server uses swap all the time, the site gets slow with no error showing. Then look at what is eating the memory, and whether the application needs to be lighter or the plan needs more RAM. See how to see what is using CPU, memory and disk on your VPS. Each plan’s specifications are on the VPS servers page. |
| Measure before and after. Run free -h in a peak before creating the swap, and again after. If the swap’s “used” stays near zero, the server was just at its limit; if it climbs and stays high, the cause is elsewhere. Other common problems are in common VPS and Cloud errors. |
|
Does the server still run out of memory? Tell us the plan and what runs on it. Open a support ticket |
|
SEE ALSO Out of memory on a VPS: what the OOM killer is and what to do How to see what is using CPU, memory and disk on your VPS |
RECOMMENDED PRODUCT VPS server with root access Resources of your own, the OS you choose, reinstall whenever you like. from 456,30 MT/mo (3-year plan, with coupon) See plans |
- 0 Users Found This Useful











