Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Disable swap or follow cPanel recommandation?

Discussion in 'CloudLinux' started by DennisMidjord, Feb 21, 2019.

  1. DennisMidjord

    DennisMidjord Well-Known Member

    Joined:
    Sep 27, 2016
    Messages:
    205
    Likes Received:
    18
    Trophy Points:
    18
    Location:
    Denmark
    cPanel Access Level:
    Root Administrator
    CloudLinux recommands that you create a 0.5GB swap (or no swap at all) while cPanel recommends 4GB if you have more than 4GB of RAM.

    Any advise on this?
     
  2. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    5,815
    Likes Received:
    444
    Trophy Points:
    233
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @DennisMidjord

    If you have a large amount of RAM you more than likely won't want any swap but if you're running under 4GB I would personally add 4GB, Cloudlinux's recommendation is a minimum. Ultimately with smaller amounts of memory, you increase your risk of running out of memory, swap helps a bit to alleviate this concern.

    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. DennisMidjord

    DennisMidjord Well-Known Member

    Joined:
    Sep 27, 2016
    Messages:
    205
    Likes Received:
    18
    Trophy Points:
    18
    Location:
    Denmark
    cPanel Access Level:
    Root Administrator
    Does this also apply to virtual servers?
    Our servers run 24GB of memory, and CentOS' default partitioning is setting up swap partitions of 12GB's.
     
  4. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    5,815
    Likes Received:
    444
    Trophy Points:
    233
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @DennisMidjord


    I won't be able to tell you what will work best for you but RedHat has some good information on this:
    Chapter 7. Swap Space - Red Hat Customer Portal

    You should have 1/2 of the full amount of RAM allocated to swap. So in your case 24GB of RAM would be 12GB of SWAP.

    In most cases, though this is a really unnecessary amount and in your case you'd most likely be fine without SWAP.

    RedHat also has this article which discusses whether or not it's actually needed Do we really need swap on modern systems?

    Essentially, I can't tell you what's right for you but hopefully, the information provided will help you make the decision.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. DennisMidjord

    DennisMidjord Well-Known Member

    Joined:
    Sep 27, 2016
    Messages:
    205
    Likes Received:
    18
    Trophy Points:
    18
    Location:
    Denmark
    cPanel Access Level:
    Root Administrator
    That was what we did. This caused issues with CloudLinux' OOM killer. I think it still sees available memory even though all RAM has been used up. This has happened a couple of times, and the server would become so slow we couldn't even gain access to it.
     
  6. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,893
    Likes Received:
    152
    Trophy Points:
    343
    cPanel Access Level:
    Root Administrator
    If you're using swap memory then you have a real risk of disk thrashing (assuming these are spindle disks and not SSD).

    Just my opinion... but if you are using more than 1 or 2GB of swap memory, then your server is overloaded. You shouldn't be swapping out memory like that. If you're using more than 24GB of memory, then the server is overloaded.

    If you have 8GB of RAM (maybe as little as 4GB) then having swap memory is less of a concern. If your server is needing more RAM than that, then you need a bigger server.

    About the only time swap space makes sense is for low memory VPSs that don't necessarily see a lot of activity but need to temporarily hold something in memory. Such as ClamAV. ClamAV can consume 1GB of memory on its own. If a VPS only has 1GB or 2GB of memory, then having swap space available for ClamAV to sit in might be beneficial. But if that VPS is receiving a lot of mail or otherwise using ClamAV a lot then it's going to be constantly swapping that memory in and out of swap space - disk thrashing.
     
    cPanelLauren likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice