Dradden45

Active Member
Sep 7, 2012
37
2
8
cPanel Access Level
Root Administrator
From what i know it is more a failsafe to keep your server from crashing if it runs out of ram. But I need to be sure so i am asking here.

My current dedicated server running WHM/Cpanel has more ram than I'll probably ever use and runs on SSD drives so disk space is it a premium.

So if I have more ram than what will ever be used do I really need to add a swap file?
 

movielad

Well-Known Member
May 14, 2003
108
2
168
cPanel Access Level
Root Administrator
Twitter
From what i know it is more a failsafe to keep your server from crashing if it runs out of ram. But I need to be sure so i am asking here.

My current dedicated server running WHM/Cpanel has more ram than I'll probably ever use and runs on SSD drives so disk space is it a premium.

So if I have more ram than what will ever be used do I really need to add a swap file?
It's not necessary, but it is recommended.

My own company does not provide swap files/partitions with our virtual private servers as we discovered far too many people taking out low spec servers with cPanel/WHM and the combined system I/O across those servers swapping memory in and out resulted in substantial performance degradation.

You'll find a lot of VPS web hosts do not provide swap by default. Some will allow you to use a swap file, but not all.

Martyn
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello :)

I've moved this thread to our "Optimization" forum.

Thank you.
 

hydn79

Active Member
Feb 1, 2013
26
1
53
cPanel Access Level
Website Owner
It's important. You can avoid the kernel's OOM killer from shutting down services like MySQL abruptly.

If hosts allows you can manually add swap using the following commands as root:
Code:
fallocate -l xG /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
xG = in gigabytes. Eg. 8G for 8gb swap.

Auto swapon during boot. Edit /etc/fstab and add at the end:
Code:
/swapfile   none    swap    sw    0   0