1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Q] LXC configuration wizard: what is "CPU limit" & "CPU unit"?

Discussion in 'Proxmox VE: Installation and configuration' started by c.monty, Jul 3, 2015.

  1. c.monty

    c.monty Member

    Joined:
    Mar 4, 2014
    Messages:
    87
    Likes Received:
    0
    Hello!

    What is the relation of the parameters "CPU limit" & "CPU unit" requested in the configuration wizard (see screenshot) when creating LXC container to CPU sockets / CPU cores?

    THX Auswahl_071.png
     
  2. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    15,347
    Likes Received:
    171
    There is no direct relation, because sockets/cores are just attributes describing the processor architecture,
    and we simply use the host architecture for containers. CPU limit/units are CFS scheduler settings, which are now available
    for containers and kvm VMs.

    CPU units is a CFS scheduler feature described here (cpu.shares):

    https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt

    CPU limit refers to 'cfs_period_us' feature described here:

    https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt

    So CPU limit is basically the maximum number of cores a container can utilize.
     
  3. c.monty

    c.monty Member

    Joined:
    Mar 4, 2014
    Messages:
    87
    Likes Received:
    0
    Hi,thanks for the quick reply.

    Are there any best practices for these settings?
    Can you document these parameters in Wiki?
    And how can I check how many CPU units are available on my host?
    The command "vzcpucheck" is not working on PVE 4.

    THX
     
    #3 c.monty, Jul 3, 2015
    Last edited: Aug 7, 2015
  4. c.monty

    c.monty Member

    Joined:
    Mar 4, 2014
    Messages:
    87
    Likes Received:
    0
    Any update?
     
  5. t.lamprecht

    t.lamprecht Proxmox Staff Member
    Staff Member

    Joined:
    Jul 28, 2015
    Messages:
    709
    Likes Received:
    57
    Hello.

    You haven't a fixed number of units (=shares), think of them like priorities:
    For example if you have 4 containers and give CT A 500 shares, CT B 250 shares and CT C 100 shares. This means A will get 5 times the CPU of container C and 2 times the CPU of container B.

    There aren't any best practices as they're use case specific. Best is to set them for your needs. If you want all containers to get equal CPU time set them all to the same value. If you have a CT which runs a important service maybe give it a bit more.

    And we're also really happy if a user contributes to the PVE Wiki, would be great! Al though we try to expand it also, naturally.

    EDIT:
    btw. "vzcpucheck" doesn't work anymore as it was an OpenVZ tool, and so not part of PVE4 which switched from OpenVZ to LXC.
     
    #5 t.lamprecht, Aug 7, 2015
    Last edited: Aug 7, 2015
  6. ianux

    ianux New Member

    Joined:
    Oct 13, 2015
    Messages:
    19
    Likes Received:
    0
    But this is not the number of CPUs presented to the CT. I set cpu limit = 2 on a container and htop display all the CPUs of the host, all of them working every now and then. cat /proc/cpuinfo show all CPUs, not the number assign by cpu limit. That can be misleading about the actual power available to the CT.
     
  7. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    15,347
    Likes Received:
    171
    You can simply use KVM if you want full virtualization. IMHO CPU limit work greats, and there is no real reason to limit the number of visible CPUs for containers.
     
  8. dignus

    dignus Member

    Joined:
    Feb 12, 2009
    Messages:
    95
    Likes Received:
    0
    The weird thing is that I was able to bring a 12 core box down with an LXC container, limited to 1.
     
  9. gkovacs

    gkovacs Member

    Joined:
    Dec 22, 2008
    Messages:
    477
    Likes Received:
    23
    I disagree Dietmar. When containers are sold as vps, there should be a clear understanding of cpu resources for the customers. If they see 8 cores after buying a single core vps, they will have no incentive to upgrade, regardless of the fact that cpulimit will limit their actual share of processor resources.

    So if possible, I would like to request that LXC containers work the same way az OpenVZ containers: show only the number of processors that are available to a container.
     
    Spazmic likes this.
  10. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    15,347
    Likes Received:
    171
    I would accept patches if someone finds a better way to do it.
     
  11. dignus

    dignus Member

    Joined:
    Feb 12, 2009
    Messages:
    95
    Likes Received:
    0
    Dietmar,

    AFAIK when LXD will be stable, it'll, work this way, also with the possibility to limit IOPS (when it's finished). Are there any plans to integrate LXD and with it LXC 2.0 ?
     
  12. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    15,347
    Likes Received:
    171
    LXD uses LXC, so if LXD can do it, we can also do it. But so far I have not seen any patches.

    This question makes no sense to me.
     
  13. gkovacs

    gkovacs Member

    Joined:
    Dec 22, 2008
    Messages:
    477
    Likes Received:
    23
  14. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    15,347
    Likes Received:
    171
    We also use the same lxcfs.
     
  15. gkovacs

    gkovacs Member

    Joined:
    Dec 22, 2008
    Messages:
    477
    Likes Received:
    23
    In that case, could you enable the bind-mounts of the replacement /proc files to show actual cpu number (cpu limit) and swap size available to a container?

     
    #15 gkovacs, Dec 8, 2015
    Last edited: Dec 8, 2015
    dlasher likes this.
  16. Patrick Zippenfenig

    Joined:
    Mar 27, 2014
    Messages:
    38
    Likes Received:
    3
    @gkovacs You can assign single cores to lxc containers with "lxc.cgroup.cpuset.cpus = 2,3" for cores 3 and 4 in /etc/pve/lxc/<ID>.conf and it will correctly display only 2 cpus in /proc/cpuinfo.

    I recently stumbled across this issue as facter for puppet reported always all cores of the host system.

    Are there any other options to limit the displayed amount of cpus in /proc/cpuinfo? Lxcfs seems only to use cpusets
     
  17. gkovacs

    gkovacs Member

    Joined:
    Dec 22, 2008
    Messages:
    477
    Likes Received:
    23
    Thanks for this information. Problem is, assigning specific cores to containers would seriously impair fair scheduling on the host. As it's impossible to predict how much load one container would put on a specific core, it would be very hard to divide the available cores evenly between containers, most likely resulting in overloading some of the cores (while others would stay inactive).

    OpenVZ did provide a translation between scheduled CPU time on the host and virtual cores in the guest, so if you had 2 cores assigned to a container, it would show precisely how much load they had when viewed in the guest. Hopefully someone will do that for lxcfs.
     
    Spazmic likes this.
  18. Fixweb

    Fixweb New Member

    Joined:
    Mar 10, 2016
    Messages:
    5
    Likes Received:
    2
    Any news of it ?
    I totally agree with gkovacs, its essential for a lot of people/companies to show a fixed number of cores and not all the host cores.
    A lot of Proxmox users are totally lost with the new improvements of Proxmox4. The main problems are :

    - Core limiting in the container
    - Container storage saved as .raw instead of folder
    - Impossibility to downsize the storage size of a container on the fly
     
    Spazmic and dlasher like this.
  19. johnnyb911

    johnnyb911 New Member

    Joined:
    Apr 29, 2016
    Messages:
    2
    Likes Received:
    0
    Hello,

    Same problems :

    - Core limiting in the container
    - Container storage saved as .raw instead of folder
    - Impossibility to downsize the storage size of a container on the fl

    Is there a bug tracker ?

    Thank you
     
  20. sahostking

    sahostking Member

    Joined:
    Oct 6, 2015
    Messages:
    224
    Likes Received:
    5
    Did you guys figure the out. Especially the core limiting?
     

Share This Page