1

I am reading openstack cloud administrator guide. On page 47 in Flavors customization topic following terms are defined.

The optional cpu_shares element specifies the proportional weighted share for the domain. If this element is omitted, the service defaults to the OS provided defaults. There is no unit for the value, it's a relative measure based on the setting of other VMs. For example, a VM configured with value 2048 will get twice as much CPU time as a VM configured with value 1024.

The optional cpu_period element specifies the enforcement interval(unit: microseconds) for QEMU and LXC hypervisors. Within period, each VCPU of the domain will not be allowed to consume more than quota worth of runtime. The value should be in range [1000, 1000000]. A period with value 0 means no value.

The optional cpu_quota element specifies the maximum allowed bandwidth(unit: microseconds). A domain with quota as any negative value indicates that the domain has infinite bandwidth, which means that it is not bandwidth controlled. The value should be in range [1000, 18446744073709551] or less than 0. A quota with value 0 means no value. You can use this feature to ensure that all vcpus run at the same speed. An example:

nova flavor-key m1.low_cpu set cpu_quota=10000
nova flavor-key m1.low_cpu set cpu_period=20000

In that example, the instance of m1.low_cpu can only consume a maximum of 50% CPU of a physical CPU computing capability.

My Questions

What is cpu_period. In above example what does value 20000 indicating.

What is cpu_quota. In above example what does value 10000 indicating.

Can anyone please elaborate with example ?

2

In the given example cpu_period is 20,000 microseconds, cpu_quota 10,000 microseconds.

For each 20,000μs period of time m1.low_cpu is permitted to use 10,000μs of processor time.

Source: I read the quoted text 3 times.

1
  • 1
    " Within period, each VCPU of the domain will not be allowed to consume more than quota worth of runtime ". If we are assigning 20,000 microseconds out of 1000000 microseconds what does it means. It will consume 20% of total ? what is relationship between cpu_period and cpu_quota ?
    – Zain
    Oct 12 '13 at 6:52
0

(Adding a clarifying answer based on the follow up question by Zain)

You are correct in your conclusion. Referring to new --cpus setting which is basically a factor of the cpu_period and the cpu_quota, the documentation tells us that:

.. if the host machine has two CPUs and you set --cpus="1.5", the container is guaranteed at most one and a half of the CPUs. This is the equivalent of setting --cpu-period="100000" and --cpu-quota="150000". Available in Docker 1.13 and higher.

So for their example, this means that for CPU usage during 100% of total CPU period, 150% of one CPU power can be used. This is pointless for one CPU because its not possible so in that example there are 2 CPUs and therefore logically the 50% excess in that example goes to the second CPU. A simpler way to think of that example is basically a total of 75% of total CPU power for a 2 core system. In other words:
(1.5 / 2) * 100 = 75% .. where 1.5 is --cpus and 2 is the number of CPU cores.

Scaling up the number of CPUs while keeping the --cpus setting the same would effectively not allow the container to scale up along with the machine. If scaling is desired then this number must be a factor of the desired power and number of available CPUs.

Given your example, if you always wanted to cap your container to 20% of what ever total CPU resources are available you would set --cpus to: (number of CPUs) x (20/100) .. or just .. number of CPUs x 0.2

I would point out that this new --cpus setting was available after the initial question was posted and is now the setting that is recommended to be used instead of a combination of --cpu-period and --cpu-quota. Clearly it makes things simpler to understand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.