nano_cpu and cpu_shares
See original GitHub issueIn the doc, there’s (for container.run
):
cpu_shares (int) – CPU shares (relative weight).
nano_cpus (int) – CPU quota in units of 10-9 CPUs.
It looks that if I want 50% CPU, nano_cpus
should be 0.5 * 1e9
. However, that doesn’t seem to be what I see in production (if I specify 0.9 * 1e9
, I will get maybe 30% CPU utilization rate, on a single-core machine). Also, if I use a 4-core CPU, and I want to use half of it (say 2 cores), what should I specify?
Similarly, cpu_shares
is an int
. What does relative weight mean? Is that on a scale of 100, so if I use 50% of the CPU I should put 50? Again, what if I have a 4-core CPU and want to use half of it?
I would love to get more clarity on these, and ideally be added to the docs.
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top Results From Across the Web
Any body know what is NanoCPUS in inspect node response ...
, NanoCPUs is defined as the CPU shares in units of 1/1e9 (or 10^-9 ) of the CPU. In other words, NanoCPUs is...
Read more >what's the difference between CpuCound vs NanoCpus for a ...
but if I use docker container create --name my_container --cpus=4 , I'll get: > docker inspect my_container | grep Cpu "CpuShares": 0, "NanoCpus...
Read more >Runtime options with Memory, CPUs, and GPUs
--cpu-shares does not prevent containers from being scheduled in swarm mode. It prioritizes container CPU resources for the available CPU cycles.
Read more >Docker cpu resource limits - NoDrama DevOps
CPU shares. The cpu-shares option allows you to specify the relative share of cpu a container will receive when there is contention for...
Read more >Docker Bootcamp – Resource Limits - Perficient Blogs
Used with cpu-period to configure the cpu scheduler. Sets the scheduler limit per period. –cpu-shares, -c, O, CPU Shares (weight relative to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is a more comprehensive source: https://docs.docker.com/engine/admin/resource_constraints/#cpu which better describes what happens in a multi CPU scenario.
I don’t know that there is a way to say “use any 2 CPUs”, but you may wanna ask on the forums as it’s a bit outside my area of expertise.
What does “counterpart” mean? And
cpus
(cpu-period
,cpu-quota
) only mentions 1 CPU scenario. What happens when there are more CPUs?And is there an option to assign CPU numbers, not specific CPUs? Say I have two containers, each wanting 2 cores. Do I need to assign specific cores (1,2; 3,4) to them, or is there a way to tell them to use 2 cores each?
Thanks!