Prevent network congestion with bandwidth limits
Create a QoS policy to limit bandwidth on networks, ports, floating IPs, or gateway IPs.
Before you begin
- Your administrator has enabled the Networking service with the
qosservice plugin. (The plugin is loaded by default.) - The administrator has created a project for you and has provided you with a
clouds.yamlfile for you to access the cloud. - The
python-openstackclientpackage is on your workstation.$ dnf list installed python-openstackclient
Procedure
- Confirm that the system
OS_CLOUDvariable is set for your cloud:$ echo $OS_CLOUD my_cloudReset the variable if necessary:
$ export OS_CLOUD=my_other_cloudAs an alternative, you can specify the cloud name by adding the
--os-cloud <cloud_name>option each time you run anopenstackcommand. - Confirm that the
qosservice plugin is loaded in the Networking service:$ openstack network qos policy listIf the
qosservice plugin is not loaded, then you receive aResourceNotFounderror, and you must load theqosservices plugin before you can continue. For more information, see your RHOSO administrator. - Identify the ID of the project you want to create the QoS policy for:
$ openstack project list- Sample output
-
+----------------------------------+----------+ | ID | Name | +----------------------------------+----------+ | 4b0b98f8c6c040f38ba4f7146e8680f5 | auditors | | 519e6344f82e4c079c8e2eabb690023b | services | | 80bf5732752a41128e612fe615c886c6 | demo | | 98a2f53c20ce4d50a40dac4a38016c69 | admin | +----------------------------------+----------+
- Using the project ID from the previous step, create a QoS policy for the project.
- Example
-
In this example, a QoS policy named
bw-limiteris created for theadminproject:$ openstack network qos policy create --share --project 98a2f53c20ce4d50a40dac4a38016c69 bw-limiter
- Configure the rules for the policy.
Note You can add more than one rule to a policy, if the type or direction of each rule is different. For example, You can specify two bandwidth-limit rules, one with egress and one with ingress direction.
- Example
-
In this example, QoS ingress and egress rules are created for the policy named
bw-limiterwith a bandwidth limit of50000kbps and a maximum burst size of50000kbps:$ openstack network qos rule create --type bandwidth-limit \ --max-kbps 50000 --max-burst-kbits 50000 --ingress bw-limiter $ openstack network qos rule create --type bandwidth-limit \ --max-kbps 50000 --max-burst-kbits 50000 --egress bw-limiter
- You can create a port with a policy attached to it, or attach a policy to a pre-existing port.
- Example - create a port with a policy attached
-
In this example, the policy
bw-limiteris associated with portport2:$ openstack port create --qos-policy bw-limiter --network private port2 - Sample output
-
+-----------------------+--------------------------------------------------+ | Field | Value | +-----------------------+--------------------------------------------------+ | admin_state_up | UP | | allowed_address_pairs | | | binding_host_id | | | binding_profile | | | binding_vif_details | | | binding_vif_type | unbound | | binding_vnic_type | normal | | created_at | 2024-09-19T19:20:24Z | | data_plane_status | None | | description | | | device_id | | | device_owner | | | dns_assignment | None | | dns_name | None | | extra_dhcp_opts | | | fixed_ips | ip_address='192.0.2.210', subnet_id='292f8c-...' | | id | f51562ee-da8d-42de-9578-f6f5cb248226 | | ip_address | None | | mac_address | fa:16:3e:d9:f2:ba | | name | port2 | | network_id | 55dc2f70-0f92-4002-b343-ca34277b0234 | | option_name | None | | option_value | None | | port_security_enabled | False | | project_id | 98a2f53c20ce4d50a40dac4a38016c69 | | qos_policy_id | 8491547e-add1-4c6c-a50e-42121237256c | | revision_number | 6 | | security_group_ids | 0531cc1a-19d1-4cc7-ada5-49f8b08245be | | status | DOWN | | subnet_id | None | | tags | [] | | trunk_details | None | | updated_at | 2024-09-19T19:23:00Z | +-----------------------+--------------------------------------------------+ - Example - attach a policy to a pre-existing port
-
In this example, the policy
bw-limiteris associated withport1:$ openstack port set --qos-policy bw-limiter port1