3.5.3. Configuring the Number of I/O Operations Per Second

In OpenVZ, you can limit the maximum number of disk input and output operations per second virtual machines and containers are allowed to perform (known as the IOPS limit). You may consider setting the IOPS limit for virtual machines and containers with high disk activities to ensure that they do not affect the performance of other virtual machines and containers on the Node.

Note

Note: By default all I/O inside containers is cached and the direct access flag (O_DIRECT) is ignored when opening files. This significantly reduces the number of IOPS required for container workload and helps avoid I/O bottlenecks on the Node. For instructions on how to configure honoring of the O_DIRECT flag inside containers, see Section 3.5.3.1, “Setting the Direct Access Flag Inside Containers” below.

By default, IOPS is not limited for newly created virtual machines and containers. To set the IOPS limit, you can use the --iopslimit option of the prlctl set command. For example, to allow the container MyCT and the virtual machine MyVM to perform no more than 100 disk I/O operations per second, you can run the following commands:

# prlctl set MyCT --iopslimit 100
# prlctl set MyVM --iopslimit 100

To ensure that the IOPS limit has been successfully applied to the container MyCT and the virtual machine MyVM, check the cgroup /sys/fs/cgroup/beancounter/<UUID>/beancounter.iopslimit.speed. For example:

# cat /sys/fs/cgroup/beancounter/`vzlist MyCT -Ho uuid`/beancounter.iopslimit.speed
100

At any time, you can remove the set IOPS limits by running this command:

# prlctl set MyCT --iopslimit 0
# prlctl set MyVM --iopslimit 0