3.4.4. Configuring Traffic Shaping

Traffic shaping (also known as network bandwidth management) allows you to control what network bandwidth a virtual machine or container may use for outgoing traffic. This feature is disabled by default.

Note

Notes:

  1. Traffic within a host cannot be shaped in the current version of OpenVZ. This includes traffic between virtual machines and containers on the same host and between those and the host itself.
  2. Incoming traffic cannot be shaped for virtual machines and containers in the current version of OpenVZ.

The following parameters control traffic shaping in OpenVZ:

  • TRAFFIC_SHAPING, enables and disables traffic shaping.
  • BANDWIDTH, sets bandwidth for specific network adapters.
  • TOTALRATE, sets the size of a bandwidth pool divided between virtual machines and containers on the host.
  • RATEMPU, limits packet rate in addition to byte rate.
  • RATE, sets a bandwidth guarantee for virtual machines and containers.
  • RATEBOUND, forces RATE as a limit.

Traffic shaping in OpenVZ works as follows. The bandwidth pool for a given network class (set by TOTALRATE) is divided among the virtual machines and containers transmitting data proportionally to their RATE settings. If the sum of RATE values of all virtual machines and containers transmitting data does not exceed TOTALRATE, each virtual machine or container gets the bandwidth equal to or greater than its RATE value (unless RATEBOUND is enabled for said virtual machine or container). If the sum of RATE values of all virtual machines and containers transmitting data exceeds the TOTALRATE value, each virtual machine or container may get less than its RATE value.

To enable and configure traffic shaping, do the following:

  1. Set the value of TRAFFIC_SHAPING to yes in the global configuration file /etc/vz/vz.conf.
  2. Set the parameters BANDWIDTH, TOTALRATE in /etc/vz/vz.conf.
  3. If required, set the optional parameters RATEMPU, RATE, RATEBOUND in /etc/vz/vz.conf.
  4. If required, set RATE and RATEBOUND for specific virtual machines and containers with prlctl set --rate and prlctl set --ratebound commands.
  5. To apply changes, restart either the virtual machines and containers for which changes have been made or the hardware node itself if the changes are global.

The following sections provide more details on and explain how to set traffic shaping parameters listed above.