The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Swap | Is it really needed?

Discussion in 'Workarounds and Optimization' started by Dradden45, Feb 1, 2015.

  1. Dradden45

    Dradden45 Active Member

    Joined:
    Sep 7, 2012
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    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?
     
  2. movielad

    movielad Well-Known Member
    PartnerNOC

    Joined:
    May 14, 2003
    Messages:
    107
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    DataCenter Provider
    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
     
  3. Dradden45

    Dradden45 Active Member

    Joined:
    Sep 7, 2012
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Great information movielad.

    Thank You.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    667
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  5. hydn79

    hydn79 Member

    Joined:
    Feb 1, 2013
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    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
     
Loading...

Share This Page