Setting CPU limits for a flavor

In addition to defining the number of vCPUs assigned to an instance, limits on the use of these CPU cycles can be further imposed. Nova relies on the underlying hypervisor for the specific implementation of the CPU limits, and thus the values available may vary. Our example is based on QEMU/KVM.

CPU limits are a special case of flavor attributes that you may encounter.

Getting ready

To add a CPU limit to a flavor, you will need the following:

  • The openstack command-line client
  • The openrc file containing appropriate credentials
  • The name of the flavor to change
  • The values you would like to set the CPU limit to (share of time the allotted CPU is allowed to consume in milliseconds per cycle)

These values in our example are as follows:

  • cpu_quota = 5000 ms
  • cpu_period = 2500 ms

How to do it…

The following commands are used to add CPU limits to a flavor.

Tip

CPU limits are not applied live. Rather, they are applied on instance launch.

At the time of this writing, the openstack command-line client is the only way to view and change this setting. It is also not shown by default when viewing instance attributes.

  1. First, view the current attributes of the flavor that we are changing, noting that we have no properties set:
    openstack flavor show openstack.cookbook
    

    This gives the following output:

    How to do it…
  2. Add the CPU limit:
    openstack flavor set
        --property quota:cpu_quota=5000
        --property quota:cpu_period=2500
        openstack.cookbook
    

    Tip

    This command shows no output when successful

  3. View the CPU limit by interrogating the flavor again, noting the properties field:
    openstack flavor show openstack.cookbook
    

    This gives an output like the following:

    How to do it…

How it works…

In order to help mitigate the noisy neighbor issue, or to provide further definition of service levels, OpenStack supports CPU limits. In OpenStack, this is called the Instance Resource Quota. CPU limits are part of the flavor definition. Meaning, all instances of a given flavor will have the same CPU limits.

Imposing CPU limits are hypervisor specific. For KVM/libvirt environments, CPU limits are enforced using cgroups, using a combination of the following three values:

  • cpu_shares
  • cpu_quota
  • cpu_period

A full discussion of what these values are and how they interact is beyond the scope of this book. However, you can find a detailed explanation of them on the OpenStack wiki at the following:

https://wiki.openstack.org/wiki/InstanceResourceQuota

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.205.172