Announcement

Collapse
No announcement yet.

cpu limit discrepancy in top command output

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • cpu limit discrepancy in top command output

    Hi,

    I was testing cpu limit feature and noticed that in the top commands output, the percentage of CPU usage for given user is wrong. Maybe cpu limits haven got applied properly ?

    I set this for a user

    lvectl set 500 --cpu=2 --ncpu=1

    Then tested it by running a high cpu consuming test php script through lve_wrapper and in top command I see this much usage..

    {

    Code:
    478397 testuser   39  19 98.5m  688  600 R 31.4  0.0   0:06.32 seq
    
    478539 testuser   20   0  151m 8820 5828 R  0.6  0.0   0:00.02 php-cgi
    
    475195 testuser   20   0  105m 1948 1552 S  0.0  0.0   0:00.06 bash
    
    478394 testuser   20   0  6132  456  372 S  0.0  0.0   0:00.00 lve_wrapper
    
    478395 testuser   20   0  249m  11m 7428 S  0.0  0.0   0:00.01 php
    
    478396 testuser   20   0  103m 1288 1108 S  0.0  0.0   0:00.00 sh
    It seems to have applied the logic of 2% * 16 CPU cores = 32% of CPU.. so its allowing 32% of cpu usage to this user. But while applying cpu usage, I had specifically mentioned ncpu=1.. so it should not multiply it into 16.. Is it a kind of bug?

    Also, how do I verify ncpu limit. lvectl list does not show any field for number of cores assigned to users..?

    Regards,

  • #2
    The CPU settings is always relative to all cores on the server:

    Comment


    • #3
      Thanks, I read through the KB.

      So as per KB, if I assign 1 core to one LVE on a 16 core box, my max CPU consumption rate for that LVE is:

      (1core x 100) / 16 cores = 6.25%

      So, 6.25% is my maximum CPU usage cap.

      Also, as per KB, an LVE can not exceed above mentioned limit of 6.25% in my case, however, I can anytime reduce it down below 6.25%. I have set cpu limit to 2% so should it be the new max cpu limit since its below the upper max limit of 6.25%?

      Also, how do I verify ncpu limit. lvectl list does not show any field for number of cores assigned to users..?

      Regards,

      Comment


      • #4
        The default ncpu is 1.
        New lve-utils will show current ncpu settings (do: yum update lve-utils --enablerepo=cloudlinux-updates-testing)

        And otherwise -- yes you are correct, though you can change ncpu on the fly now.

        Comment


        • #5
          I still did not get clear idea about CPU utilization. How come its showing 32% cpu utilization in top when as per my calculation (as per KB) it should not exceed 6.25%? i.e. (1core x 100) / 16 cores = 6.25% Max

          Regards,

          Comment


          • #6
            Suhas,

            Please, post exact output, as well as your settings.

            Comment


            • #7
              Here is the output for suhas.k user with uid 32031

              Code:
              # lvectl set 32031 --cpu=2 --ncpu=1
              
              # lvectl list | egrep CPU|32031
              
              ID     CPU      IO     MEM      EP
              
              32031       2      25  262144      20
              Code:
              top - 13:46:52 up 72 days, 19:54,  4 users,  load average: 0.38, 0.59, 0.55
              
              Tasks: 471 total,   2 running, 469 sleeping,   0 stopped,   0 zombie
              
              Cpu0  :  0.7%us,  1.0%sy,  0.0%ni, 98.0%id,  0.0%wa,  0.0%hi,  0.3%si,  0.0%st
              
              Cpu1  :  3.3%us,  0.7%sy,  0.0%ni, 96.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu2  :  0.4%us,  0.0%sy,  0.0%ni, 99.6%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu3  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu4  : 15.6%us,  0.0%sy,  0.0%ni, 84.4%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu5  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu6  :  0.0%us,  0.0%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.3%si,  0.0%st
              
              Cpu7  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu8  :  1.0%us,  0.3%sy,  0.0%ni, 98.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu9  :  0.3%us,  4.0%sy,  0.0%ni, 95.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu10 : 19.3%us,  0.7%sy,  0.0%ni, 79.6%id,  0.0%wa,  0.0%hi,  0.4%si,  0.0%st
              
              Cpu11 :  1.6%us,  0.7%sy,  0.0%ni, 97.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu12 :  0.6%us,  1.0%sy,  0.0%ni, 98.4%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu13 :  0.9%us,  3.2%sy,  0.0%ni, 95.9%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu14 :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu15 :  0.3%us,  0.3%sy,  0.0%ni, 99.4%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Mem:  24537984k total, 23852060k used,   685924k free,  1425440k buffers
              
              Swap:  4194296k total,    92432k used,  4101864k free, 14558948k cached
              
              PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
              
              385518 suhas.k   20   0 98.5m  688  600 R 32.4  0.0   0:02.44 seq
              
              382185 suhas.k   20   0 99.5m 1720  804 S  0.0  0.0   0:00.00 sshd
              
              382194 suhas.k   20   0  105m 1944 1536 S  0.0  0.0   0:00.02 bash
              
              385517 suhas.k   20   0  6132  456  372 S  0.0  0.0   0:00.00 lve_wrapper
              
              874097 suhas.k   20   0  100m 3292  808 S  0.0  0.0   0:00.71 sshd
              
              874098 suhas.k   20   0  105m 1932 1536 S  0.0  0.0   0:00.01 bash
              As you can see in top output, there are 16 CPU cores and seq command that I executed to simulate high cpu usage is taking 32% CPU. (Which as per our calculation should not be more than 6.25%)

              Other info:

              If I turn Irix mode off, I see CPU usage as 2%

              Code:
              top - 13:51:03 up 72 days, 19:58,  4 users,  load average: 0.46, 0.48, 0.51
              
              Tasks: 430 total,   2 running, 428 sleeping,   0 stopped,   0 zombie
              
              Cpu0  : 34.0%us,  1.3%sy,  0.0%ni, 64.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu1  :  1.7%us,  0.7%sy,  0.0%ni, 90.5%id,  7.1%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu2  :  9.2%us, 12.5%sy,  0.0%ni, 78.3%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu3  :  1.1%us,  0.7%sy,  0.0%ni, 98.2%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu4  :  2.1%us,  0.0%sy,  0.0%ni, 97.1%id,  0.8%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu5  :  1.4%us,  0.4%sy,  0.0%ni, 97.5%id,  0.7%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu6  :  0.0%us,  0.3%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu7  :  1.1%us,  0.7%sy,  0.0%ni, 97.9%id,  0.4%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu8  :  1.2%us,  0.0%sy,  0.0%ni, 98.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu9  :  2.7%us,  1.3%sy,  0.0%ni, 95.0%id,  1.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu10 :  0.4%us,  1.2%sy,  0.0%ni, 98.0%id,  0.0%wa,  0.0%hi,  0.4%si,  0.0%st
              
              Cpu11 :  2.4%us,  4.7%sy,  0.0%ni, 92.5%id,  0.4%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu12 :  0.3%us,  0.7%sy,  0.0%ni, 99.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu13 :  3.8%us,  3.8%sy,  0.0%ni, 92.4%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu14 :  1.5%us,  0.7%sy,  0.0%ni, 97.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Cpu15 :  0.5%us,  1.0%sy,  0.0%ni, 98.5%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
              
              Mem:  24537984k total, 23933620k used,   604364k free,  1425492k buffers
              
              Swap:  4194296k total,    92432k used,  4101864k free, 14590088k cached
              
              PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
              
              387412 suhas.k   20   0 98.5m  688  600 R  2.0  0.0   0:04.32 seq
              
              382185 suhas.k   20   0 99.5m 1720  804 S  0.0  0.0   0:00.00 sshd
              
              382194 suhas.k   20   0  105m 1944 1536 S  0.0  0.0   0:00.02 bash
              
              387411 suhas.k   20   0  6132  452  372 S  0.0  0.0   0:00.00 lve_wrapper
              
              874097 suhas.k   20   0  100m 3292  808 S  0.0  0.0   0:00.73 sshd
              
              874098 suhas.k   20   0  105m 1932 1536 S  0.0  0.0   0:00.01 bash
              But it is percentage CPU usage across all cores i.e 32%/16(cores) = 2%.. but since I have already assigned only 1 core, this does not make sense.

              Correct me if I got the calculation wrong.

              Regards,

              Comment


              • #8
                I see what the confusion is. You don understand how ncpu/cpu work. They are not joined. The smallest one enforced, but one is not dependent on the other. So, if you have cpu=2% on 16 core server, it doesn matter what you pick for ncpu -- it will still mean 32% of a single core.
                If you pick 10% CPU limit, and ncpu=1, it would mean 1 core, as 160% is more then one core.
                Smallest win, but calculations are independent of each other.

                It is explained here: https://helpdesk.cloudlinux.com/inde...s-only-x-limit

                Comment

                Working...
                X