Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Support
  3. Should my swap equal my RAM?

Should my swap equal my RAM?

Scheduled Pinned Locked Moved Solved Support
ramswapmemory
6 Posts 3 Posters 1.5k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      M Offline
      masonbee
      wrote on last edited by girish
      #1

      I resized my VPS up and now I have 1GB of swap and 4GB of RAM. As apps apply half memory to swap should I increase my swap to 4GB?

      girishG 1 Reply Last reply
      0
      • M masonbee

        I resized my VPS up and now I have 1GB of swap and 4GB of RAM. As apps apply half memory to swap should I increase my swap to 4GB?

        girishG Offline
        girishG Offline
        girish
        Staff
        wrote on last edited by
        #2

        @masonbee Yes, having a bit more swap won't hurt. Please see https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/ch-swapspace for some recommendations.

        robiR M 2 Replies Last reply
        0
        • girishG girish

          @masonbee Yes, having a bit more swap won't hurt. Please see https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/ch-swapspace for some recommendations.

          robiR Offline
          robiR Offline
          robi
          wrote on last edited by
          #3

          @girish this guidance doesn't apply well to containerized environments where the system is the container.

          Having 25-50% swap space for overloaded memory conditions is ok, but in practice a large waste of space, especially in server type environments in VPS systems where they're not generous with storage or RAM.

          If memory is overcommited to a point of swap space use, in a container that means slow performance and likely a memory sizing issue, which the OOM killer will shortly remedy.

          Hence why bother with so much swap spread across so many containers halving it's limits when RAM is the actual target.

          IMO if any at all, 10%-20% would be plenty as a setting for containers. My preference is 0%.

          Conscious tech

          1 Reply Last reply
          2
          • girishG girish

            @masonbee Yes, having a bit more swap won't hurt. Please see https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/ch-swapspace for some recommendations.

            M Offline
            M Offline
            masonbee
            wrote on last edited by
            #4

            @girish Thank you. The Red Hat documentation was roughly how I was thinking of it and in that case I should be fine with 1GB of swap (as I am not suspending the server, etc...) although 2GB might be better.

            However, if i look at my apps they say, "Cloudron allocates 50% of this value as RAM and 50% as swap.". If that is a hard rule then that might explain why my apps seem to be restarting, even ones that don't get a huge amount of load (eg; low visit website), as after 8 x 256mb apps my swap space is fully allocated.

            Now, I am running 17 apps at the moment and according to System Info/System Memory this is using 3GB of memory out of "RAM (3.85 GB) + Swap (984.99 MB)" which would seem to me to be a reasonable headroom unless the swap rule is hard at which point I have (assuming 256mb apps) over 2GB allocated to swap and under 1GB available.

            So, is the swap rule hard? Because then it would seem to me to mean I need to have the same amount of swap as RAM. In my case 4GB.

            Hopefully that is clear and thank you for your former reply.

            girishG 1 Reply Last reply
            1
            • M masonbee

              @girish Thank you. The Red Hat documentation was roughly how I was thinking of it and in that case I should be fine with 1GB of swap (as I am not suspending the server, etc...) although 2GB might be better.

              However, if i look at my apps they say, "Cloudron allocates 50% of this value as RAM and 50% as swap.". If that is a hard rule then that might explain why my apps seem to be restarting, even ones that don't get a huge amount of load (eg; low visit website), as after 8 x 256mb apps my swap space is fully allocated.

              Now, I am running 17 apps at the moment and according to System Info/System Memory this is using 3GB of memory out of "RAM (3.85 GB) + Swap (984.99 MB)" which would seem to me to be a reasonable headroom unless the swap rule is hard at which point I have (assuming 256mb apps) over 2GB allocated to swap and under 1GB available.

              So, is the swap rule hard? Because then it would seem to me to mean I need to have the same amount of swap as RAM. In my case 4GB.

              Hopefully that is clear and thank you for your former reply.

              girishG Offline
              girishG Offline
              girish
              Staff
              wrote on last edited by
              #5

              @masonbee said in Should my swap equal my RAM?:

              So, is the swap rule hard?

              It's not. To better understand this: The memory allocation in the app UI is the maximum memory limit. It is not hard allocated to the app. If the app only uses 20MB of it's allocated 256MB (say), then the rest is available for other apps.

              About the swap: Note that swap is not really "used" by a process because that's not possible. An app can only use RAM and the swap is just a place in the disk to dump existing RAM to free up RAM (sorry, for my poor explanation 😉 ). So, when we say "50% is allocated for swap", it only means that the kernel is told that the app can use that much space on disk for it's own RAM.

              Practically speaking, in our case, it seems that out of 4GB, almost 3.85 GB is already used. In this case, I would give more swap. Ideally, you should give it a little bit more RAM (say 2GB) but swap is the cheaper option. The kernel will keep swapping things out as required.

              M 1 Reply Last reply
              1
              • girishG girish

                @masonbee said in Should my swap equal my RAM?:

                So, is the swap rule hard?

                It's not. To better understand this: The memory allocation in the app UI is the maximum memory limit. It is not hard allocated to the app. If the app only uses 20MB of it's allocated 256MB (say), then the rest is available for other apps.

                About the swap: Note that swap is not really "used" by a process because that's not possible. An app can only use RAM and the swap is just a place in the disk to dump existing RAM to free up RAM (sorry, for my poor explanation 😉 ). So, when we say "50% is allocated for swap", it only means that the kernel is told that the app can use that much space on disk for it's own RAM.

                Practically speaking, in our case, it seems that out of 4GB, almost 3.85 GB is already used. In this case, I would give more swap. Ideally, you should give it a little bit more RAM (say 2GB) but swap is the cheaper option. The kernel will keep swapping things out as required.

                M Offline
                M Offline
                masonbee
                wrote on last edited by
                #6

                @girish Increasing the swap seems to have cured the problem. Additionally, there may have been a problem caused by a misreading of the amount of swap as originally on the Linode it said there was only 512mb but in Cloudron it said there was almost 1GB.

                I have increased the swap from 512mb to 2048mb and I haven't received any app out of memory notifications since then so that seems to have cured it.

                Thank you for your help.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Bookmarks
                  • Search