Configuring Network Bandwidth Management
The network bandwidth for outgoing traffic a virtual machine or Container receives is controlled by two parameters: RATE and RATEBOUND .
Note: Incoming traffic cannot be controlled in the current version of Virtuozzo.
The RATE parameter specifies the guaranteed outgoing traffic rate that a virtual machine or Container receives. This rate can be specified differently for different network classes. Bandwidth values are specified in kilobits per second (Kbps). It is recommended to increase this value in 8 Kbps increments and set it to at least 8 Kbps. The example below demonstrates how to set the RATE parameter for the MyVM virtual machine and Container 101 to 16 Kbps for network class 1 on the eth0 network adapter:
# prlctl set MyVM --rate 1:16
# prlctl set 101 --rate eth0:1:16
Note: For Containers, you can also configure the RATE parameter for different network adapters. For virtual machines, you can set this parameter for the default network adapter (usually eth0 ) only. The rates for all other network adapters can be configured in the /etc/vz/vz.conf global configuration file.
The RATEBOUND parameter specifies whether the network bandwidth available to virtual machine or Container for outgoing traffic is limited by the bandwidth specified in the RATE variable. By default, this parameter is turned off for all newly created virtual machines and Containers. That means that virtual machines and Containers are allowed to take free bandwidth from the TOTALRATE pool. You can turn the RATEBOUND parameter on by using the --ratebound option of the prlctl set command, for example:
# prlctl set MyVM --ratebound on
# prlctl set 101 --ratebound on
The actual network bandwidth available to virtual machines and Containers depends on the number of virtual machines and Containers and the total sum of the RATE values, and normally does not coincide with the bandwidth specified in their own RATE parameters. If the RATEBOUND parameter is turned on, the virtual machine or Container bandwidth is limited by the value of the RATE parameter.
If the the RATE and RATEBOUND parameters are not set for individual virtual machines and Containers, the values from the /etc/vz/vz.conf configuration file are taken. By default, Virtuozzo does not set RATEBOUND , which corresponds to no , and RATE is set to eth0:1:8 .
The network bandwidth management in Virtuozzo works in the following way. The bandwidth pool for a given network class (configurable through the TOTALRATE variable in the global configuration file) is divided among the virtual machines and Containers transmitting data proportionally to their RATE settings. If the total value of the RATE variables of all virtual machines and Containers transmitting data does not exceed the TOTALRATE value, each virtual machine or Container gets the bandwidth equal or greater than its RATE value (unless the RATEBOUND variable is enabled for this virtual machine or Container). If the total value of the RATE variables of all virtual machines and Containers transmitting data exceeds the TOTALRATE value, each virtual machine or Container may get less than its RATE value.
The example below illustrates the scenario when Containers 101 and 102 have RATEBOUND set to no , and the MyVM virtual machine has RATEBOUND set to yes . With the default TOTALRATE of 4096 Kbps and RATE of 8 Kbps, the bandwidth pool will be distributed according to the following table:
Container 101
|
Container 102
|
MyVM
|
Consumed Bandwidth
|
transmits
|
idle
|
idle
|
Container 101: 4096 Kbps
|
idle
|
idle
|
transmits
|
MyVM: 8 Kbps
|
transmits
|
transmits
|
idle
|
Container 101: 2048 Kbps Container 102: 2048 Kbps
|
transmits
|
idle
|
transmits
|
Container 101: 4032 Kbps MyVM: 8 Kbps
|
transmits
|
transmits
|
transmits
|
Container 101: 2016 Kbps Container 102: 2016 Kbps MyVM: 8 Kbps
|
Once you configure the bandwidth settings, activate your changes by running the following command:
# /etc/init.d/vz shaperrestart
Stopping shaping: Ok
Starting shaping: Ok
Set shaping on running Container: Ok
This command clears off all existing shaping settings and sets them again using the configuration files of running virtual machines and Containers.
|