Skip to main content

Disable swap or follow cPanel recommandation?

Comments

5 comments

  • cPanelLauren
    Hi @DennisMidjord
    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?

    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!
    0
  • DennisMidjord
    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.
    0
  • cPanelLauren
    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.
    0
  • DennisMidjord
    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.

    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.
    0
  • sparek-3
    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.
    0

Please sign in to leave a comment.