|
| 1 | +=============== |
| 2 | +Resource Limits |
| 3 | +=============== |
| 4 | + |
| 5 | +Nova supports configuring limits on individual resources including CPU, memory, |
| 6 | +disk and network. These limits can be used to enforce basic Quality-of-Service |
| 7 | +(QoS) policies on such resources. |
| 8 | + |
| 9 | +.. note:: |
| 10 | + |
| 11 | + Hypervisor-enforced resource limits are distinct from API-enforced user and |
| 12 | + project quotas. For information on the latter, refer to :doc:`quotas`. |
| 13 | + |
| 14 | +.. warning:: |
| 15 | + |
| 16 | + This feature is poorly tested and poorly maintained. It may no longer work |
| 17 | + as expected. Where possible, consider using the QoS policies provided by |
| 18 | + other services, such as |
| 19 | + :cinder-doc:`Cinder </admin/blockstorage-basic-volume-qos.html>` and |
| 20 | + :neutron-doc:`Neutron </admin/config-qos.html>`. |
| 21 | + |
| 22 | + |
| 23 | +Configuring resource limits |
| 24 | +--------------------------- |
| 25 | + |
| 26 | +Resource quota enforcement support is specific to the virt driver in use on |
| 27 | +compute hosts. |
| 28 | + |
| 29 | +libvirt |
| 30 | +~~~~~~~ |
| 31 | + |
| 32 | +The libvirt driver supports CPU, disk and VIF limits. Unfortunately all of |
| 33 | +these work quite differently, as discussed below. |
| 34 | + |
| 35 | +CPU limits |
| 36 | +^^^^^^^^^^ |
| 37 | + |
| 38 | +Libvirt enforces CPU limits in terms of *shares* and *quotas*, configured |
| 39 | +via :nova:extra-spec:`quota:cpu_shares` and :nova:extra-spec:`quota:cpu_period` |
| 40 | +/ :nova:extra-spec:`quota:cpu_quota`, respectively. Both are implemented using |
| 41 | +the `cgroups v1 cpu controller`__. |
| 42 | + |
| 43 | +CPU shares are a proportional weighted share of total CPU resources relative to |
| 44 | +other instances. It does not limit CPU usage if CPUs are not busy. There is no |
| 45 | +unit and the value is purely relative to other instances, so an instance |
| 46 | +configured with value of 2048 will get twice as much CPU time as a VM |
| 47 | +configured with the value 1024. For example, to configure a CPU share of 1024 |
| 48 | +for a flavor: |
| 49 | + |
| 50 | +.. code-block:: console |
| 51 | +
|
| 52 | + $ openstack flavor set $FLAVOR --property quota:cpu_shares=1024 |
| 53 | +
|
| 54 | +The CPU quotas require both a period and quota. The CPU period specifies the |
| 55 | +enforcement interval in microseconds, while the CPU quota specifies the maximum |
| 56 | +allowed bandwidth in microseconds that the each vCPU of the instance can |
| 57 | +consume. The CPU period must be in the range 1000 (1mS) to 1,000,000 (1s) or 0 |
| 58 | +(disabled). The CPU quota must be in the range 1000 (1mS) to 2^64 or 0 |
| 59 | +(disabled). Where the CPU quota exceeds the CPU period, this means the guest |
| 60 | +vCPU process is able to consume multiple pCPUs worth of bandwidth. For example, |
| 61 | +to limit each guest vCPU to 1 pCPU worth of runtime per period: |
| 62 | + |
| 63 | +.. code-block:: console |
| 64 | +
|
| 65 | + $ openstack flavor set $FLAVOR \ |
| 66 | + --property quota:cpu_period=1000 \ |
| 67 | + --property quota:cpu_quota=1000 |
| 68 | +
|
| 69 | +To limit each guest vCPU to 2 pCPUs worth of runtime per period: |
| 70 | + |
| 71 | +.. code-block:: console |
| 72 | +
|
| 73 | + $ openstack flavor set $FLAVOR \ |
| 74 | + --property quota:cpu_period=1000 \ |
| 75 | + --property quota:cpu_quota=2000 |
| 76 | +
|
| 77 | +Finally, to limit each guest vCPU to 0.5 pCPUs worth of runtime per period: |
| 78 | + |
| 79 | +.. code-block:: console |
| 80 | +
|
| 81 | + $ openstack flavor set $FLAVOR \ |
| 82 | + --property quota:cpu_period=1000 \ |
| 83 | + --property quota:cpu_quota=500 |
| 84 | +
|
| 85 | +.. note:: |
| 86 | + |
| 87 | + Smaller periods will ensure a consistent latency response at the expense of |
| 88 | + burst capacity. |
| 89 | + |
| 90 | +CPU shares and CPU quotas can work hand-in-hand. For example, if two instances |
| 91 | +were configured with :nova:extra-spec:`quota:cpu_shares`\ =1024 and |
| 92 | +:nova:extra-spec:`quota:cpu_period`\ =100000 (100mS) for both, then configuring |
| 93 | +both with a :nova:extra-spec:`quota:cpu_quota`\ =75000 (75mS) will result in |
| 94 | +them sharing a host CPU equally, with both getting exactly 50mS of CPU time. |
| 95 | +If instead only one instance gets :nova:extra-spec:`quota:cpu_quota`\ =75000 |
| 96 | +(75mS) while the other gets :nova:extra-spec:`quota:cpu_quota`\ =25000 (25mS), |
| 97 | +then the first will get 3/4 of the time per period. |
| 98 | + |
| 99 | +.. __: https://man7.org/linux/man-pages/man7/cgroups.7.html |
| 100 | + |
| 101 | +Memory Limits |
| 102 | +^^^^^^^^^^^^^ |
| 103 | + |
| 104 | +The libvirt driver does not support memory limits. |
| 105 | + |
| 106 | +Disk I/O Limits |
| 107 | +^^^^^^^^^^^^^^^ |
| 108 | + |
| 109 | +Libvirt enforces disk limits through maximum disk read, write and total bytes |
| 110 | +per second, using the :nova:extra-spec:`quota:disk_read_bytes_sec`, |
| 111 | +:nova:extra-spec:`quota:disk_write_bytes_sec` and |
| 112 | +:nova:extra-spec:`quota:disk_total_bytes_sec` extra specs, respectively. It can |
| 113 | +also enforce disk limits through maximum disk read, write and total I/O |
| 114 | +operations per second, using the :nova:extra-spec:`quota:disk_read_iops_sec`, |
| 115 | +:nova:extra-spec:`quota:disk_write_iops_sec` and |
| 116 | +:nova:extra-spec:`quota:disk_total_iops_sec` extra specs, respectively. For |
| 117 | +example, to set a maximum disk write of 10 MB/sec for a flavor: |
| 118 | + |
| 119 | +.. code-block:: console |
| 120 | +
|
| 121 | + $ openstack flavor set $FLAVOR \ |
| 122 | + --property quota:disk_write_bytes_sec=10485760 |
| 123 | +
|
| 124 | +Network bandwidth limits |
| 125 | +^^^^^^^^^^^^^^^^^^^^^^^^ |
| 126 | + |
| 127 | +.. warning:: |
| 128 | + |
| 129 | + These limits are enforced via libvirt and will only work where the network |
| 130 | + is connect to the instance using a tap interface. It will not work for |
| 131 | + things like :doc:`SR-IOV VFs <pci-passthrough>`. |
| 132 | + :neutron-doc:`Neutron's QoS policies </admin/config-qos.html>` should be |
| 133 | + preferred wherever possible. |
| 134 | + |
| 135 | +Libvirt enforces network bandwidth limits through inbound and outbound average, |
| 136 | +using the :nova:extra-spec:`quota:vif_inbound_average` and |
| 137 | +:nova:extra-spec:`quota:vif_outbound_average` extra specs, respectively. |
| 138 | +In addition, optional *peak* values, which specifies the maximum rate at which |
| 139 | +a bridge can send data (kB/s), and *burst* values, which specifies the amount |
| 140 | +of bytes that can be burst at peak speed (kilobytes), can be specified for both |
| 141 | +inbound and outbound traffic, using the |
| 142 | +:nova:extra-spec:`quota:vif_inbound_peak` / |
| 143 | +:nova:extra-spec:`quota:vif_outbound_peak` and |
| 144 | +:nova:extra-spec:`quota:vif_inbound_burst` / |
| 145 | +:nova:extra-spec:`quota:vif_outbound_burst` extra specs, respectively. |
| 146 | + |
| 147 | +For example, to configure **outbound** traffic to an average of 262 Mbit/s |
| 148 | +(32768 kB/s), a peak of 524 Mbit/s, and burst of 65536 kilobytes: |
| 149 | + |
| 150 | +.. code-block:: console |
| 151 | +
|
| 152 | + $ openstack flavor set $FLAVOR \ |
| 153 | + --property quota:vif_outbound_average=32768 \ |
| 154 | + --property quota:vif_outbound_peak=65536 \ |
| 155 | + --property quota:vif_outbound_burst=65536 |
| 156 | +
|
| 157 | +.. note:: |
| 158 | + |
| 159 | + The speed limit values in above example are specified in kilobytes/second, |
| 160 | + whle the burst value is in kilobytes. |
| 161 | + |
| 162 | +VMWare |
| 163 | +~~~~~~ |
| 164 | + |
| 165 | +In contrast to libvirt, the VMWare virt driver enforces resource limits using |
| 166 | +consistent terminology, specifically through relative allocation levels, hard |
| 167 | +upper limits and minimum reservations configured via, for example, the |
| 168 | +:nova:extra-spec:`quota:cpu_shares_level` / |
| 169 | +:nova:extra-spec:`quota:cpu_shares_share`, :nova:extra-spec:`quota:cpu_limit`, |
| 170 | +and :nova:extra-spec:`quota:cpu_reservation` extra specs, respectively. |
| 171 | + |
| 172 | +Allocation levels can be specified using one of ``high``, ``normal``, ``low``, |
| 173 | +or ``custom``. When ``custom`` is specified, the number of shares must be |
| 174 | +specified using e.g. :nova:extra-spec:`quota:cpu_shares_share`. There is no |
| 175 | +unit and the values are relative to other instances on the host. The upper |
| 176 | +limits and reservations, by comparison, are measure in resource-specific units, |
| 177 | +such as MHz for CPUs and will ensure that the instance never used more than or |
| 178 | +gets less than the specified amount of the resource. |
| 179 | + |
| 180 | +CPU limits |
| 181 | +^^^^^^^^^^ |
| 182 | + |
| 183 | +CPU limits are configured via the :nova:extra-spec:`quota:cpu_shares_level` / |
| 184 | +:nova:extra-spec:`quota:cpu_shares_share`, :nova:extra-spec:`quota:cpu_limit`, |
| 185 | +and :nova:extra-spec:`quota:cpu_reservation` extra specs. |
| 186 | + |
| 187 | +For example, to configure a CPU allocation level of ``custom`` with 1024 |
| 188 | +shares: |
| 189 | + |
| 190 | +.. code-block:: console |
| 191 | +
|
| 192 | + $ openstack flavor set $FLAVOR \ |
| 193 | + --quota:cpu_shares_level=custom \ |
| 194 | + --quota:cpu_shares_share=1024 |
| 195 | +
|
| 196 | +To configure a minimum CPU allocation of 1024 MHz and a maximum of 2048 MHz: |
| 197 | + |
| 198 | +.. code-block:: console |
| 199 | +
|
| 200 | + $ openstack flavor set $FLAVOR \ |
| 201 | + --quota:cpu_reservation=1024 \ |
| 202 | + --quota:cpu_limit=2048 |
| 203 | +
|
| 204 | +Memory limits |
| 205 | +^^^^^^^^^^^^^ |
| 206 | + |
| 207 | +Memory limits are configured via the |
| 208 | +:nova:extra-spec:`quota:memory_shares_level` / |
| 209 | +:nova:extra-spec:`quota:memory_shares_share`, |
| 210 | +:nova:extra-spec:`quota:memory_limit`, and |
| 211 | +:nova:extra-spec:`quota:memory_reservation` extra specs. |
| 212 | + |
| 213 | +For example, to configure a memory allocation level of ``custom`` with 1024 |
| 214 | +shares: |
| 215 | + |
| 216 | +.. code-block:: console |
| 217 | +
|
| 218 | + $ openstack flavor set $FLAVOR \ |
| 219 | + --quota:memory_shares_level=custom \ |
| 220 | + --quota:memory_shares_share=1024 |
| 221 | +
|
| 222 | +To configure a minimum memory allocation of 1024 MB and a maximum of 2048 MB: |
| 223 | + |
| 224 | +.. code-block:: console |
| 225 | +
|
| 226 | + $ openstack flavor set $FLAVOR \ |
| 227 | + --quota:memory_reservation=1024 \ |
| 228 | + --quota:memory_limit=2048 |
| 229 | +
|
| 230 | +Disk I/O limits |
| 231 | +^^^^^^^^^^^^^^^ |
| 232 | + |
| 233 | +Disk I/O limits are configured via the |
| 234 | +:nova:extra-spec:`quota:disk_io_shares_level` / |
| 235 | +:nova:extra-spec:`quota:disk_io_shares_share`, |
| 236 | +:nova:extra-spec:`quota:disk_io_limit`, and |
| 237 | +:nova:extra-spec:`quota:disk_io_reservation` extra specs. |
| 238 | + |
| 239 | +For example, to configure a disk I/O allocation level of ``custom`` with 1024 |
| 240 | +shares: |
| 241 | + |
| 242 | +.. code-block:: console |
| 243 | +
|
| 244 | + $ openstack flavor set $FLAVOR \ |
| 245 | + --quota:disk_io_shares_level=custom \ |
| 246 | + --quota:disk_io_shares_share=1024 |
| 247 | +
|
| 248 | +To configure a minimum disk I/O allocation of 1024 MB and a maximum of 2048 MB: |
| 249 | + |
| 250 | +.. code-block:: console |
| 251 | +
|
| 252 | + $ openstack flavor set $FLAVOR \ |
| 253 | + --quota:disk_io_reservation=1024 \ |
| 254 | + --quota:disk_io_limit=2048 |
| 255 | +
|
| 256 | +Network bandwidth limits |
| 257 | +^^^^^^^^^^^^^^^^^^^^^^^^ |
| 258 | + |
| 259 | +Network bandwidth limits are configured via the |
| 260 | +:nova:extra-spec:`quota:vif_shares_level` / |
| 261 | +:nova:extra-spec:`quota:vif_shares_share`, |
| 262 | +:nova:extra-spec:`quota:vif_limit`, and |
| 263 | +:nova:extra-spec:`quota:vif_reservation` extra specs. |
| 264 | + |
| 265 | +For example, to configure a network bandwidth allocation level of ``custom`` |
| 266 | +with 1024 shares: |
| 267 | + |
| 268 | +.. code-block:: console |
| 269 | +
|
| 270 | + $ openstack flavor set $FLAVOR \ |
| 271 | + --quota:vif_shares_level=custom \ |
| 272 | + --quota:vif_shares_share=1024 |
| 273 | +
|
| 274 | +To configure a minimum bandwidth allocation of 1024 Mbits/sec and a maximum of |
| 275 | +2048 Mbits/sec: |
| 276 | + |
| 277 | +.. code-block:: console |
| 278 | +
|
| 279 | + $ openstack flavor set $FLAVOR \ |
| 280 | + --quota:vif_reservation=1024 \ |
| 281 | + --quota:vif_limit=2048 |
| 282 | +
|
| 283 | +Hyper-V |
| 284 | +~~~~~~~ |
| 285 | + |
| 286 | +CPU limits |
| 287 | +^^^^^^^^^^ |
| 288 | + |
| 289 | +The Hyper-V driver does not support CPU limits. |
| 290 | + |
| 291 | +Memory limits |
| 292 | +^^^^^^^^^^^^^ |
| 293 | + |
| 294 | +The Hyper-V driver does not support memory limits. |
| 295 | + |
| 296 | +Disk I/O limits |
| 297 | +^^^^^^^^^^^^^^^ |
| 298 | + |
| 299 | +Hyper-V enforces disk limits through maximum total bytes and total I/O |
| 300 | +operations per second, using the :nova:extra-spec:`quota:disk_total_bytes_sec` |
| 301 | +and :nova:extra-spec:`quota:disk_total_iops_sec` extra specs, respectively. For |
| 302 | +example, to set a maximum disk read/write of 10 MB/sec for a flavor: |
| 303 | + |
| 304 | +.. code-block:: console |
| 305 | +
|
| 306 | + $ openstack flavor set $FLAVOR \ |
| 307 | + --property quota:disk_total_bytes_sec=10485760 |
| 308 | +
|
| 309 | +Network bandwidth limits |
| 310 | +^^^^^^^^^^^^^^^^^^^^^^^^ |
| 311 | + |
| 312 | +The Hyper-V driver does not support network bandwidth limits. |
0 commit comments