question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nano_cpu and cpu_shares

See original GitHub issue

In 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:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
shin-commented, Aug 29, 2017

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.

1reaction
danqingcommented, Aug 29, 2017

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found