It is often necessary to limit the amount of traffic the particular environment can use or guarantee some minimum traffic rate to an environment.
How can it be achieved with Virtuozzo or Virtuozzo сontainers?
Presently, only outgoing traffic is managed. Incoming traffic shaping is resource inefficient and implementation details are being checked in the internal request #PSBM-17545 if this can be supported in the future. This kind of traffic management is not yet implemented to avoid performance degradation and high resource consumption: if packets are delivered to the host server, it is better to pass them to the virtual environment.
To enable outgoing traffic shaping, define network classes as described in the documentation. By default, there is one network class defined: whole IP address space. You might need different classes and limits for locally accessible resources.
From the overall
bandwidth of the physical interface, some rate can be reserved for the hardware node. This is achieved by setting
totalrate to value lower than the interface's bandwidth. Since
totalrate is defined on per-class basis and classes are mutually exclusive, the amount of reserved rate for the node will be calculated as sum of
totalrate values extracted from
Every virtual environment can be configured to have certain
rate from the configured
totalrate, per every network class. If the environment should be limited to that
rate and not able to consume more network speed than this value, it should have
ratebound set to "yes".
All these parameters are described in the documentation.
Example of configuration
Let us assume that there is an interface
eth0 connected to the 1GBit local network and with the external connection with 100MBit and with 10Mbit external traffic reserved for the node's needs. With this setup, there can be two network classes, one - local network, and another - external network.
Configure network classes in
1 0.0.0.0/0 2 172.16.0.0/20 ## replace this range with the proper one
Configure network shaping settings in the global configuration file
BANDWIDTH="eth0:1000000" ## 1Gbit local connection TOTALRATE="eth0:1:90000 eth0:2:900000" ## 90Mbit for class 1, 900Mbit for class 2 to all VEs RATE="eth0:1:1000 eth0:2:50000" ## 1Mbit for class 1, 50Mbit for class 2 for a VE by default RATEBOUND="yes" ## set RATE as limit by default TRAFFIC_SHAPING="yes"
(Please note, "RATE" and "RATEBOUND" are applicable to containers only. Virtual machines should be configured explicitly.)
Start network traffic shaping:
~# service vz shaperon
- Configure traffic shaping details for environments as described in the documentation.
Configuring in VA
Please follow the below mentioned document to configure traffic shaping in VA: