Docker CPU usage: change % to be relative to allocated resources

Recommended Posts

Currently Docker CPU usage shown on Docker page shows CPU usage as a percentage of the full system core count, unfortunately this behaviour extends to when a container has CPUs pinned, which is where a user has configured the container with less CPU cores (vcpu).

In this example on a 32 vcpu machine, and with a container configured for only 2 vcpu shows a less meaningful fractional percentage.

Instead I propose this usage should be based on actual available vcpu, which is more meaningful for the purpose of monitoring cpu usage. 


The below mockup shows current metrics, and the same usage if displayed relative to allocated resources.


Note that container memory usage already displays this relative behaviour.

This machine has 64GB of RAM, but this container is restricted to 8GB though extra parameter --memory=8GB


Container CPU pinning for context


  • Like 1
Link to comment

Yeah, currently the stats are returned directly via "docker stats" divided by the core count in the system (so it's normalized to a max of 100% - docker stats by itself would actually return 0.52*32 = 16.64%) While I don't have any real issues with what you're proposing, one downside is that if you ever add up the percentages they could quite easily exceed 100% 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.