doudi8829 2016-02-29 05:39
浏览 498
已采纳

在docker cpu用法计算中,什么是:TotalUsage,SystemUsage,PercpuUsage,计算的含义是什么?

I see in docker sources for cpu calculation but I don't get what are exactly

  1. TotalUsage
  2. SystemUsage
  3. PercpuUsage

why is cpuDelta divided by SystemDelta and also why then multiplied by PercpuUsage?

The documentation says for cpuDelta

// calculate the change for the cpu usage of the container in between readings

and for systemDelta:

// calculate the change for the entire system between readings

so shouldn't these delta's both be summed and divided by the total cpu (or total nanoseconds passed) during that delta time? after all the container was consuming both the cpuDelta and also systemDelta

Update: I think I get it the totalUsage is the container usage and the SystemUsage is not the systemCPU used by the container but the whole system beyond the container cpu this is why they are divided.

  • 写回答

2条回答 默认 最新

  • duanmeng1950 2016-02-29 08:09
    关注

    There was a similar discussion in issue 18615 which led to PR 13627 "Update "docker stats " calculations"

    I think cpuPercent = (cpuDelta / systemDelta) * float64(len(v.CpuStats.CpuUsage.PercpuUsage)) is right, because:

    • cpuDelta is total time consumed of all cores and
    • systemDelta is also the total time consumed of all cores,

    so (cpuDelta / systemDelta) is the average cpu usage of each core, so it need multiply the number of cpu cores to calculate the total cpu usage.

    for example, on a 4-core system, cpu usage can be anywhere between 0 and 400%, so it has to be multiplied by the number of cores.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?