-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker stats API response not matching with actual usage in container #8640
Comments
Hi Wending, |
VIC relies on reading VM sample from vCenter performance apis( vic/pkg/vsphere/performance/vm_collector.go Line 241 in b5678ad
|
And to add to issue Summary., |
@aviratna As containers are VMs in VIC, the behavior for CPU percentages is different. Can you please post the results you are getting from docker stats vs what the expected results should be? An example would help and elaborating on the use-case will give more context to the team. This will help in bringing the gap in understanding of the responses and if they need to be changed in future. |
This is by design, because each VCH is a virtual docker host, and each container VM's cpu usage is the percentage of the total CPU MHZ allocated to the corresponding VCH resource pool. The calculation formula of cpu percentage displayed by docker stats is: float64(container vm cpu usage)/float64(VCH CPU limit) *(container vm vcpu number). How to view VCH CPU limit? |
@ading007 @arslanabbasi @wjun : Thanks for response. I think above formula of CPU% against total CPU resources of boundary is more applicable in nested container scenario where containers are running inside VM. While in case of VIC as every container is VM in backend CPU% should be actual actual CPU utilization of that container/VM. If we apply same formula of traditional docker for VIC Container CPU utilization value will not be correct. Base on code snippet by @wjun it looks like VCH is calling vCenter API to get the actual stats for VM however when we call stats API it doesn't give actual utilization of that container (VM). |
Summary
I'm trying to calculate CPU usage from docker stats response json. We observed that "system_cpu_usage" from "cpu_stats" and "precpu_stats" are always same in every response from VCH and it is giving invalid CPU usage details upon using CPU calculation.
vmstat/top is showing 100% and stats API response gave 0.36% upon calculation, even admiral showing 0.36% as utilization at same time. Would like to check if it is known issue or any mis-configuration on VCH causing this issue. Could you give us some pointers to debug more on this.
FYI, we used CPU calculation from here.,
https://github.com/docker/docker/blob/eb131c5383db8cac633919f82abad86c99bffbe5/cli/command/container/stats_helpers.go#L175
Environment information
VMware Product: VMware vCenter Server
VMware OS: linux-x64
VMware OS version: 6.7.0
Server: 1.5.4
See also
Troubleshooting attempted
The text was updated successfully, but these errors were encountered: