Jump to: navigation, search

Difference between revisions of "InstanceResourceQuota"

(Configure Nova to use these feathers)
(Instance Resource Quota)
 
(8 intermediate revisions by 5 users not shown)
Line 2: Line 2:
 
= Instance Resource Quota =
 
= Instance Resource Quota =
  
How to set Server CPU,disk IO,Bandwidth consumption limit for instances using the new feature of nova.
+
Each nova flavor can be assigned extra specs which allow to specify resources quota/limits.
By using cgroup,libvirt can set the per instance CPU time consumption percent. and the instances's read_iops,read_byteps,
+
Currently these limits can be applied to CPU, disk IO and network bandwidth.
write_iops,write_byteps.also libvirt support limit the instances in/out bandwidth.
+
 
 +
'''Extra specs?'''
 +
<br />
 +
Extra specs are additional information set per flavor. They are used here to apply quota but there are not limited to this feature. One can set extra specs to specify where a kind of flavor must be run, etc.
  
 
https://blueprints.launchpad.net/nova/+spec/quota-instance-resource
 
https://blueprints.launchpad.net/nova/+spec/quota-instance-resource
 +
<br />
 +
 +
== How it works ==
 +
 +
Nova can use libvirt features to set limits when a new VM is spawned.
 +
 +
=== CPU ===
  
== Configure Nova to use these feathers ==
+
CPU quota are handled by using [http://en.wikipedia.org/wiki/Cgroups cgroups].
  
Config IO limit for the specified instance type
+
=== IO ===
  
<pre><nowiki>  
+
IO throttling are handled by [http://wiki.qemu.org/Features/DiskIOLimits QEMU]. It's like using libvirt's blk'''dev'''iotune.<br />
 +
Note that libvirt has also a blkiotune feature that make use of cgroups but this is not used by Nova.
 +
 
 +
=== Network ===
 +
 
 +
Traffic shaping -- i.e. limit inbound/outbound bandwidth -- is achieved by using [http://lartc.org/manpages/tc.txt tc].
 +
Note that libvirt uses tc to allow traffic shaping by network interface. If libvirt was using cgroups to control bandwidth, all network interfaces of a guest would be constrained since cgroups work at process level.
 +
<br />
 +
 
 +
== Configure Nova via CLI ==
 +
 
 +
The following examples make use of nova-manage and python-novaclient.
 +
 
 +
=== IO limits ===
 +
 
 +
Since QEMU 1.1
 +
 
 +
Nova Extra Specs keys:
 +
 
 +
* disk_write_bytes_sec
 +
* disk_read_bytes_sec
 +
* disk_read_iops_sec
 +
* disk_write_iops_sec
 +
* disk_total_bytes_sec
 +
* disk_total_iops_sec
 +
<br />
 +
 
 +
==== Examples ====
 +
 
 +
nova-manage:
 +
 
 +
<pre><nowiki>
 
nova-manage flavor set_key --name m1.small  --key quota:disk_read_bytes_sec --value 10240000
 
nova-manage flavor set_key --name m1.small  --key quota:disk_read_bytes_sec --value 10240000
 
nova-manage flavor set_key --name m1.small  --key quota:disk_write_bytes_sec --value 10240000
 
nova-manage flavor set_key --name m1.small  --key quota:disk_write_bytes_sec --value 10240000
 +
</nowiki></pre>
  
or using python-novaclient with admin credentials
+
python-novaclient with admin credentials:
  
 +
<pre><nowiki>
 
nova flavor-key m1.small  set quota:disk_read_bytes_sec=10240000
 
nova flavor-key m1.small  set quota:disk_read_bytes_sec=10240000
 
nova flavor-key m1.small  set quota:disk_write_bytes_sec=10240000
 
nova flavor-key m1.small  set quota:disk_write_bytes_sec=10240000
 
</nowiki></pre>
 
</nowiki></pre>
 +
<br />
  
 +
=== CPU limits ===
  
CPU control params :cpu_shares,cpu_quota,cpu_period
+
Nova Extra Specs keys:
  
shares
+
* cpu_shares
 +
* cpu_quota
 +
* cpu_period
 +
<br />
 +
 
 +
'''cpu_shares'''
  
 
The optional shares element specifies the proportional weighted share for the domain. If this is omitted, it defaults to the OS provided defaults. NB, There is no unit for the value, it's a relative measure based on the setting of other VM, e.g. A VM configured with value 2048 will get twice as much CPU time as a VM configured with value 1024. Since 0.9.0
 
The optional shares element specifies the proportional weighted share for the domain. If this is omitted, it defaults to the OS provided defaults. NB, There is no unit for the value, it's a relative measure based on the setting of other VM, e.g. A VM configured with value 2048 will get twice as much CPU time as a VM configured with value 1024. Since 0.9.0
  
period
+
'''cpu_period'''
  
The optional period element specifies the enforcement interval(unit: microseconds). 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. Only QEMU driver support since 0.9.4, LXC since 0.9.10
+
The optional period element specifies the enforcement interval (unit: microseconds). 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. Only QEMU driver support since 0.9.4, LXC since 0.9.10
  
quota
+
'''cpu_quota'''
  
The optional 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. Only QEMU driver support since 0.9.4, LXC since 0.9.10
+
The optional quota element specifies the maximum allowed bandwidth (unit: microseconds). A domain with a negative quota 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. Only QEMU driver support since 0.9.4, LXC since 0.9.10.
  
Config CPU limit for the specified instance type
+
==== Examples ====
 +
 
 +
nova-manage:
  
 
<pre><nowiki>
 
<pre><nowiki>
 
nova-manage flavor set_key --name m1.small  --key quota:cpu_quota --value 5000
 
nova-manage flavor set_key --name m1.small  --key quota:cpu_quota --value 5000
 
nova-manage flavor set_key --name m1.small  --key quota:cpu_period --value 2500
 
nova-manage flavor set_key --name m1.small  --key quota:cpu_period --value 2500
 +
</nowiki></pre>
  
or using python-novaclient with admin credentials
+
python-novaclient with admin credentials:
  
 +
<pre><nowiki>
 
nova flavor-key m1.small  set quota:cpu_quota=10240000
 
nova flavor-key m1.small  set quota:cpu_quota=10240000
 
nova flavor-key m1.small  set quota:cpu_period=10240000
 
nova flavor-key m1.small  set quota:cpu_period=10240000
 
</nowiki></pre>
 
</nowiki></pre>
 +
<br />
  
 +
=== Bandwidth limits ===
  
bandwidth params :vif_inbound_average,vif_inbound_peak,vif_inbound_burst,vif_outbound_average,vif_outbound_peak,vif_outbound_burst
+
Nova Extra Specs keys:
  
Incoming and outgoing traffic can be shaped independently. The bandwidth element can have at most one inbound and at most one outbound child elements. Leaving any of these children element out result in no QoS applied on that traffic direction. So, when you want to shape only network's incoming traffic, use inbound only, and vice versa. Each of these elements have one mandatory attribute average. It specifies average bit rate on interface being shaped. Then there are two optional attributes: peak, which specifies maximum rate at which bridge can send data, and burst, amount of bytes that can be burst at peak speed. Accepted values for attributes are integer numbers, The units for average and peak attributes are kilobytes per second, and for the burst just kilobytes. The rate is shared equally within domains connected to the network.
+
* vif_inbound_average
 +
* vif_outbound_average
 +
* vif_inbound_peak
 +
* vif_outbound_peak
 +
* vif_inbound_burst
 +
* vif_outbound_burst
 +
<br />
  
Config Bandwidth limit for instance network traffic
+
Incoming and outgoing traffic can be shaped independently. The bandwidth element can have at most one inbound and at most one outbound child elements. Leaving any of these children element out result in no QoS applied on that traffic direction. So, when you want to shape only network's incoming traffic, use inbound only, and vice versa. Each of these elements have one mandatory attribute average. It specifies average bit rate on interface being shaped. Then there are two optional attributes: peak, which specifies maximum rate at which bridge can send data, and burst, amount of bytes that can be burst at peak speed. Accepted values for attributes are integer numbers, The units for average and peak attributes are kilobytes per second, and for the burst just kilobytes. The rate is shared equally within domains connected to the network. See [http://libvirt.org/formatnetwork.html#elementQoS libvirt QoS].
 +
 
 +
==== Examples ====
 +
 
 +
nova-manage:
  
 
<pre><nowiki>
 
<pre><nowiki>
 
nova-manage flavor set_key --name m1.small  --key quota:vif_inbound_average --value 10240
 
nova-manage flavor set_key --name m1.small  --key quota:vif_inbound_average --value 10240
 
nova-manage flavor set_key --name m1.small  --key quota:vif_outbound_average --value 10240
 
nova-manage flavor set_key --name m1.small  --key quota:vif_outbound_average --value 10240
 +
</nowiki></pre>
  
or using python-novaclient with admin credentials
+
python-novaclient with admin credentials:
  
 +
<pre><nowiki>
 
nova flavor-key m1.small  set quota:vif_inbound_average=10240
 
nova flavor-key m1.small  set quota:vif_inbound_average=10240
 
nova flavor-key m1.small  set quota:vif_outbound_average=10240
 
nova flavor-key m1.small  set quota:vif_outbound_average=10240
 
</nowiki></pre>
 
</nowiki></pre>
 +
<br />
 +
 +
=== Memory limits ===
 +
 +
Currently there is no implementation of libvirt memtune in nova.
 +
See https://blueprints.launchpad.net/nova/+spec/flavor-quota-memory
 +
 +
=== Unset limits ===
 +
 +
To unset a quota, just run:
 +
 +
<pre><nowiki>
 +
nova flavor-key <flavor> unset <key>
 +
</nowiki></pre>
 +
<br />
 +
 +
==== Example ====
 +
 +
<pre><nowiki>
 +
nova flavor-key m1.small unset quota:vif_inbound_average
 +
</nowiki></pre>
 +
<br />
 +
 +
== Configure Nova via Horizon ==
 +
 +
The aforementioned examples make use of nova-manage and python-novaclient but extra specs can also be set in Horizon.
 +
<br />
 +
 +
With admin credentials, go to [Admin] > [System] > [Flavors] to display all the flavors . Click on "More" on the right of a flavor and choose "View Extra Specs" in the dropdown menu.
 +
Now you can add extra specs by clicking on "Create".
 +
 +
[[Category: Nova]]

Latest revision as of 19:54, 12 September 2017

Instance Resource Quota

Each nova flavor can be assigned extra specs which allow to specify resources quota/limits. Currently these limits can be applied to CPU, disk IO and network bandwidth.

Extra specs?
Extra specs are additional information set per flavor. They are used here to apply quota but there are not limited to this feature. One can set extra specs to specify where a kind of flavor must be run, etc.

https://blueprints.launchpad.net/nova/+spec/quota-instance-resource

How it works

Nova can use libvirt features to set limits when a new VM is spawned.

CPU

CPU quota are handled by using cgroups.

IO

IO throttling are handled by QEMU. It's like using libvirt's blkdeviotune.
Note that libvirt has also a blkiotune feature that make use of cgroups but this is not used by Nova.

Network

Traffic shaping -- i.e. limit inbound/outbound bandwidth -- is achieved by using tc. Note that libvirt uses tc to allow traffic shaping by network interface. If libvirt was using cgroups to control bandwidth, all network interfaces of a guest would be constrained since cgroups work at process level.

Configure Nova via CLI

The following examples make use of nova-manage and python-novaclient.

IO limits

Since QEMU 1.1

Nova Extra Specs keys:

  • disk_write_bytes_sec
  • disk_read_bytes_sec
  • disk_read_iops_sec
  • disk_write_iops_sec
  • disk_total_bytes_sec
  • disk_total_iops_sec


Examples

nova-manage:

nova-manage flavor set_key --name m1.small  --key quota:disk_read_bytes_sec --value 10240000
nova-manage flavor set_key --name m1.small  --key quota:disk_write_bytes_sec --value 10240000

python-novaclient with admin credentials:

nova flavor-key m1.small  set quota:disk_read_bytes_sec=10240000
nova flavor-key m1.small  set quota:disk_write_bytes_sec=10240000


CPU limits

Nova Extra Specs keys:

  • cpu_shares
  • cpu_quota
  • cpu_period


cpu_shares

The optional shares element specifies the proportional weighted share for the domain. If this is omitted, it defaults to the OS provided defaults. NB, There is no unit for the value, it's a relative measure based on the setting of other VM, e.g. A VM configured with value 2048 will get twice as much CPU time as a VM configured with value 1024. Since 0.9.0

cpu_period

The optional period element specifies the enforcement interval (unit: microseconds). 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. Only QEMU driver support since 0.9.4, LXC since 0.9.10

cpu_quota

The optional quota element specifies the maximum allowed bandwidth (unit: microseconds). A domain with a negative quota 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. Only QEMU driver support since 0.9.4, LXC since 0.9.10.

Examples

nova-manage:

nova-manage flavor set_key --name m1.small  --key quota:cpu_quota --value 5000
nova-manage flavor set_key --name m1.small  --key quota:cpu_period --value 2500

python-novaclient with admin credentials:

nova flavor-key m1.small  set quota:cpu_quota=10240000
nova flavor-key m1.small  set quota:cpu_period=10240000


Bandwidth limits

Nova Extra Specs keys:

  • vif_inbound_average
  • vif_outbound_average
  • vif_inbound_peak
  • vif_outbound_peak
  • vif_inbound_burst
  • vif_outbound_burst


Incoming and outgoing traffic can be shaped independently. The bandwidth element can have at most one inbound and at most one outbound child elements. Leaving any of these children element out result in no QoS applied on that traffic direction. So, when you want to shape only network's incoming traffic, use inbound only, and vice versa. Each of these elements have one mandatory attribute average. It specifies average bit rate on interface being shaped. Then there are two optional attributes: peak, which specifies maximum rate at which bridge can send data, and burst, amount of bytes that can be burst at peak speed. Accepted values for attributes are integer numbers, The units for average and peak attributes are kilobytes per second, and for the burst just kilobytes. The rate is shared equally within domains connected to the network. See libvirt QoS.

Examples

nova-manage:

nova-manage flavor set_key --name m1.small  --key quota:vif_inbound_average --value 10240
nova-manage flavor set_key --name m1.small  --key quota:vif_outbound_average --value 10240

python-novaclient with admin credentials:

nova flavor-key m1.small  set quota:vif_inbound_average=10240
nova flavor-key m1.small  set quota:vif_outbound_average=10240


Memory limits

Currently there is no implementation of libvirt memtune in nova. See https://blueprints.launchpad.net/nova/+spec/flavor-quota-memory

Unset limits

To unset a quota, just run:

nova flavor-key <flavor> unset <key>


Example

nova flavor-key m1.small unset quota:vif_inbound_average


Configure Nova via Horizon

The aforementioned examples make use of nova-manage and python-novaclient but extra specs can also be set in Horizon.

With admin credentials, go to [Admin] > [System] > [Flavors] to display all the flavors . Click on "More" on the right of a flavor and choose "View Extra Specs" in the dropdown menu. Now you can add extra specs by clicking on "Create".