Openvswitch – Setting a bandwidth limit

If you read the manual page for ovs-vsctl command you’ll find the Configuration Cookbook section. Using the QoS example, I’ve tried to set a bandwidth limit to one of my virtual machine’s network interface (vnet2).

The QoS cam be enforced using Linux HTB (Linux Hierarchical Token Bucket please read) or Linux HSFC (Linux Hierarchical Fair Service Curve please read)  and I’ve called the configuration newqos following the example. In that configuration I’ve set a maximum rate of 4 Mbps (4000000 bits per second) and  one QoS queue called q0 with a maximum and minimum bandwidth rate of 4 Mbps. The newqos configuration is applied to the vnet2 openvswitch port which is the eth0 network interface for my virtual machine:

ovs-vsctl -- set Port vnet2 qos=@newqos -- \
--id=@newqos create QoS type=linux-htb other-config:max-rate=4000000 queues=0=@q0 -- \
--id=@q0   create   Queue   other-config:min-rate=4000000 other-config:max-rate=4000000

Before setting the QoS I started to download a 2 GB file. You can notice in the following rrdtool graph that after applying the QoS configuration, the rate is reduced to 4 Mbps so Openvswitch is working just fine. After removing the QoS configuration, the bandwidth starts to rise again. Openvswitch is awesome!.

bandwith_test

If you want to remove the qos, do what the man page says:

ovs-vsctl clear Port vnet2 qos

Enjoy!

Advertisements

2 thoughts on “Openvswitch – Setting a bandwidth limit

  1. Cosmin says:

    Very useful tutorial.
    I cannot figure out the following issue:
    “ovs-vsctl clear Port vnet2 qos” removes the created QoS rule from the port, but how can I completely delete the QoS?
    If I do “ovs-vsctl list QoS” I can still see all the QoS entries that I have created throughout time.

    Thanks!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s