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. Feature Requests
  3. New app install CPU share : change default

New app install CPU share : change default

Scheduled Pinned Locked Moved Feature Requests
12 Posts 5 Posters 1.5k Views 5 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.
    • timconsidineT Offline
      timconsidineT Offline
      timconsidine
      App Dev
      wrote on last edited by
      #1

      Seems default max CPU share for any new app from Cloudron App Store is set to 50%.

      This doesn't make sense to me, except in the context of a server running only a few apps.
      But many here (including me) run a large number of apps, many of which do not deserve high CPU priority.

      Rather than changing every app down from 50% to 25% or 13%, isn't more sensible to set a lower default, and leave it to the user to increase if needed.
      After all, that's the approach taken for RAM allocation.

      It would be heaven to set RAM and CPU share as a parameter when installing, but that's more complexity and dev work which doesn't justify time, effort, feature stability risk.
      But just changing the default value in the app's App Store manifest is low time/low risk exercise.

      Just my 2p.

      1 Reply Last reply
      1
      • humptydumptyH Offline
        humptydumptyH Offline
        humptydumpty
        wrote on last edited by humptydumpty
        #2

        Cool suggestion but I never understood how to allocate cpu shares. I’ve been leaving it all at default. The graph shows usage/spikes over 100% sometimes which doesn’t make sense at all. RAM is more straightforward. I agree, not all apps should have priority shares and you’ve got my upvote, but I’d like the staff to explain cpu usage if implemented.

        1 Reply Last reply
        0
        • robiR Offline
          robiR Offline
          robi
          wrote on last edited by
          #3

          They're just upper limits of overall CPU(s) available for the app container. Just like RAM.

          Conscious tech

          humptydumptyH 1 Reply Last reply
          0
          • robiR robi

            They're just upper limits of overall CPU(s) available for the app container. Just like RAM.

            humptydumptyH Offline
            humptydumptyH Offline
            humptydumpty
            wrote on last edited by
            #4

            @robi okay, but here are some more questions/concerns.

            • what happens when an app reaches the limit (say 20%)? Does it throttle speeds or crash like when an app runs OOM?

            • we have “recommended/minimum” RAM figures to use for each app, but no info on CPU usage. If the staff assign a global default, then some apps might need more cpu shares. In this case, how do I figure out what’s the lowest number of shares we should set to run the app reliably?

            • how would this work if it’s percentage based since each VPS has different resources? 10% might work fine on one VPS but crash on another ($5 droplet).

            robiR 1 Reply Last reply
            0
            • humptydumptyH humptydumpty

              @robi okay, but here are some more questions/concerns.

              • what happens when an app reaches the limit (say 20%)? Does it throttle speeds or crash like when an app runs OOM?

              • we have “recommended/minimum” RAM figures to use for each app, but no info on CPU usage. If the staff assign a global default, then some apps might need more cpu shares. In this case, how do I figure out what’s the lowest number of shares we should set to run the app reliably?

              • how would this work if it’s percentage based since each VPS has different resources? 10% might work fine on one VPS but crash on another ($5 droplet).

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

              @humptydumpty said in New app install CPU share : change default:

              @robi okay, but here are some more questions/concerns.

              • what happens when an app reaches the limit (say 20%)? Does it throttle speeds or crash like when an app runs OOM?

              No, it just slows down.

              • we have “recommended/minimum” RAM figures to use for each app, but no info on CPU usage. If the staff assign a global default, then some apps might need more cpu shares. In this case, how do I figure out what’s the lowest number of shares we should set to run the app reliably?

              There is no need to that. See above.

              • how would this work if it’s percentage based since each VPS has different resources? 10% might work fine on one VPS but crash on another ($5 droplet).

              Again, it cannot crash from CPU limits. Only RAM and how the app handles running out of memory.

              CPUs are shared in time, up to % of overall CPU(s).

              RAM is not shared, but used in chunks up to an individual and then overall physical limit.

              Conscious tech

              humptydumptyH 1 Reply Last reply
              1
              • robiR robi

                @humptydumpty said in New app install CPU share : change default:

                @robi okay, but here are some more questions/concerns.

                • what happens when an app reaches the limit (say 20%)? Does it throttle speeds or crash like when an app runs OOM?

                No, it just slows down.

                • we have “recommended/minimum” RAM figures to use for each app, but no info on CPU usage. If the staff assign a global default, then some apps might need more cpu shares. In this case, how do I figure out what’s the lowest number of shares we should set to run the app reliably?

                There is no need to that. See above.

                • how would this work if it’s percentage based since each VPS has different resources? 10% might work fine on one VPS but crash on another ($5 droplet).

                Again, it cannot crash from CPU limits. Only RAM and how the app handles running out of memory.

                CPUs are shared in time, up to % of overall CPU(s).

                RAM is not shared, but used in chunks up to an individual and then overall physical limit.

                humptydumptyH Offline
                humptydumptyH Offline
                humptydumpty
                wrote on last edited by
                #6

                @robi thanks for the explanation!

                robiR 1 Reply Last reply
                0
                • humptydumptyH humptydumpty

                  @robi thanks for the explanation!

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

                  @humptydumpty You're welcome.

                  Don't be afraid to test it by setting the CPU shares really low and observe what happens.

                  Conscious tech

                  1 Reply Last reply
                  1
                  • girishG Offline
                    girishG Offline
                    girish
                    Staff
                    wrote on last edited by girish
                    #8

                    This doesn't actually allocate CPU the way you think. As @robi pointed out, it allocates cpu shares - how much to allocate to which app when resources are short. By default, app sees all the CPU

                    I will refer https://docs.docker.com/config/containers/resource_constraints/#cpu :

                    Set this flag to a value greater or less than the default of 1024 to increase or reduce the container's weight,
                    and give it access to a greater or lesser proportion of the host machine's CPU cycles. **This is only enforced
                    when CPU cycles are constrained.** When plenty of CPU cycles are available, all containers use as much CPU
                    as they need. In that way, this is a soft limit. --cpu-shares doesn't prevent containers from being scheduled in
                    Swarm mode. It prioritizes container CPU resources for the available CPU cycles. It doesn't guarantee or 
                    reserve any specific CPU access.
                    

                    In practice, I have found this very hard to "measure". I tried to summarize the above in https://docs.cloudron.io/apps/#cpu-shares (screenshot) but maybe it's not clear enough.

                    jdaviescoatesJ 1 Reply Last reply
                    2
                    • timconsidineT Offline
                      timconsidineT Offline
                      timconsidine
                      App Dev
                      wrote on last edited by
                      #9

                      No, I think I understand the concept of CPU shares.
                      I just think it is bizarre / bad practice to set the default to 50%.

                      If the setting has a practical impact when overall system is under load, then why set it high for all apps as a default.
                      If it doesn't have a practical impact, why bother having it OR why set it at 50% ?

                      Anyway, it doesn't really matter, I guess.

                      jdaviescoatesJ 1 Reply Last reply
                      0
                      • timconsidineT timconsidine

                        No, I think I understand the concept of CPU shares.
                        I just think it is bizarre / bad practice to set the default to 50%.

                        If the setting has a practical impact when overall system is under load, then why set it high for all apps as a default.
                        If it doesn't have a practical impact, why bother having it OR why set it at 50% ?

                        Anyway, it doesn't really matter, I guess.

                        jdaviescoatesJ Offline
                        jdaviescoatesJ Offline
                        jdaviescoates
                        wrote on last edited by
                        #10

                        @timconsidine said in New app install CPU share : change default:

                        I just think it is bizarre / bad practice to set the default to 50%.

                        Why? have you actually hit a problem of some some sort that requires a solution?

                        @timconsidine said in New app install CPU share : change default:

                        If it doesn't have a practical impact, why bother having it

                        Fair question, i guess.

                        @timconsidine said in New app install CPU share : change default:

                        Anyway, it doesn't really matter, I guess.

                        My thoughts exactly.

                        I think the only time I've ever adjusted mine has been to give Nextcloud even more than 50% (I've given it 75%) in the hope it might help speed it up.

                        Oh, and on one of my PeerTube instance too (a transcoding videos seems to one of the few things I do on my server that actually eats up a fair bit of CPU).

                        @humptydumpty said in New app install CPU share : change default:

                        The graph shows usage/spikes over 100% sometimes which doesn’t make sense at all

                        That's when there are multiple CPUs (which there normally are). My server seemingly has 12 CPUs as my graph goes up to 1200% (but in the last 30 days it's never actually gone above 225%)

                        I use Cloudron with Gandi & Hetzner

                        1 Reply Last reply
                        0
                        • girishG girish

                          This doesn't actually allocate CPU the way you think. As @robi pointed out, it allocates cpu shares - how much to allocate to which app when resources are short. By default, app sees all the CPU

                          I will refer https://docs.docker.com/config/containers/resource_constraints/#cpu :

                          Set this flag to a value greater or less than the default of 1024 to increase or reduce the container's weight,
                          and give it access to a greater or lesser proportion of the host machine's CPU cycles. **This is only enforced
                          when CPU cycles are constrained.** When plenty of CPU cycles are available, all containers use as much CPU
                          as they need. In that way, this is a soft limit. --cpu-shares doesn't prevent containers from being scheduled in
                          Swarm mode. It prioritizes container CPU resources for the available CPU cycles. It doesn't guarantee or 
                          reserve any specific CPU access.
                          

                          In practice, I have found this very hard to "measure". I tried to summarize the above in https://docs.cloudron.io/apps/#cpu-shares (screenshot) but maybe it's not clear enough.

                          jdaviescoatesJ Offline
                          jdaviescoatesJ Offline
                          jdaviescoates
                          wrote on last edited by
                          #11

                          @girish said in New app install CPU share : change default:

                          I tried to summarize the above in https://docs.cloudron.io/apps/#cpu-shares (screenshot) but maybe it's not clear enough.

                          You've written there:

                          The CPU share setting is a percentage relative to each app

                          Does that mean that if one leaves all the apps on 50% the setting is basically doing nothing? But that any more/ less than 50% would give relatively more/ less CPU time to that app?

                          I use Cloudron with Gandi & Hetzner

                          girishG 1 Reply Last reply
                          1
                          • jdaviescoatesJ jdaviescoates

                            @girish said in New app install CPU share : change default:

                            I tried to summarize the above in https://docs.cloudron.io/apps/#cpu-shares (screenshot) but maybe it's not clear enough.

                            You've written there:

                            The CPU share setting is a percentage relative to each app

                            Does that mean that if one leaves all the apps on 50% the setting is basically doing nothing? But that any more/ less than 50% would give relatively more/ less CPU time to that app?

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

                            @jdaviescoates yes, that's my understanding. setting it all to 50% means you are not giving any app any "preference".

                            1 Reply Last reply
                            4
                            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