How does CPU utilization in container affects host?

Hello,

I run WCF IIS container which deliberatly pegs CPU and monitoring host at the same time and can not see how high CPU utilization in container translates into CPU utilization on host. Below are output from container as well as a host at the same time. I don’t see any container related processes on host using any CPU yet container is above 50%.

Container
[d2e3b47377fb…]: PS C:\Users\ContainerAdministrator\Documents> get-process | Sort-Object CPU -descending

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    475     326   133792     111508      64.22   2392   1 w3wp
    540      43    51388      75944       6.17   2692   1 powershell
   4903       0      128        128       5.84      4   0 System
    521      39    59424      72636       4.59   1864   1 powershell

Host
PS D:\docker> get-process | sort-object CPU -Des | select -First 10

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
   3526       0      164      15396   5,874.08      4   0 System
   2967     195   326588     163788   2,069.80   9728   1 chrome
    396      28    26240      10200   1,664.50   1516   0 BESClient
    556      12     7740      10604   1,476.34    100   0 services
    433      12     8072      11840   1,428.23  11640   0 audiodg
    248      31     9276      14588   1,387.95  10872   1 nvtray
    771      32   153352      82824   1,258.45   5900   0 mcshield
    181      13    62900      10028   1,010.64   4304   0 vmware-usbarbitrator64
    823      64   233544     143716     920.00   1348   1 dwm
   3452    1048   375824     395076     809.97   9140   1 explorer

Relevant parts of docker inspect for container

“Isolation”: “hyperv”,
“CpuShares”: 0,
“Memory”: 0,
“NanoCpus”: 0,
“CgroupParent”: “”,
“BlkioWeight”: 0,
“BlkioWeightDevice”: null,
“BlkioDeviceReadBps”: null,
“BlkioDeviceWriteBps”: null,
“BlkioDeviceReadIOps”: null,
“BlkioDeviceWriteIOps”: null,
“CpuPeriod”: 0,
“CpuQuota”: 0,
“CpuRealtimePeriod”: 0,
“CpuRealtimeRuntime”: 0,
“CpusetCpus”: “”,
“CpusetMems”: “”,
“Devices”: null,
“DiskQuota”: 0,
“KernelMemory”: 0,
“MemoryReservation”: 0,
“MemorySwap”: 0,
“MemorySwappiness”: null,
“OomKillDisable”: null,
“PidsLimit”: 0,
“Ulimits”: null,
“CpuCount”: 0,

Is this using process or hyper-v isolation? With hyper-v isolation, you should see a worker process, with process isolation you’d expect to see the container processes directly on the host.

Yes, Hyper-V isolation will not show CPU usage in Task Manager but will show in PerfMon. To get CPU utilization inside Hyper-V container use following powershell. Where $ID variable is ID of running container

get-counter "\Hyper-V Hypervisor Virtual Processor($($ID):Hv VP 0)\% Guest Run Time"

Timestamp                 CounterSamples
---------                 --------------
1/27/2017 4:04:38 PM      \\computer\hyper-v hypervisor virtual
                          processor(823cfbcfbe690a126d2bfeb08ed04b7af69a60396892e06f9ed20c0e84dbd01f:hv vp 0)\% guest run
                          time :
                          0.058378899421981