Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to limit the Block IO of a container

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to limit the Block IO of containers, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Block IO is another resource that can limit the use of containers. Block IO refers to the read and write of the disk. Docker can control the bandwidth of the read and write disk of the container by setting weights and limiting bps and iops, as discussed below.

Note: the Block IO quota is currently valid only for direct IO (without file caching).

Block IO weight

By default, all containers can read and write disks equally, and the priority of the container block IO can be changed by setting the-- blkio-weight parameter.

-- blkio-weight is similar to-- cpu-shares in that it sets the relative weight value, which defaults to 500. In the following example, the bandwidth of the container_A read and write disk is twice that of container_B.

Docker run-it-- name container_A-- blkio-weight 600 ubuntu

Docker run-it-name container_B-blkio-weight 300 ubuntu

Restrict bps and iops

Bps is the amount of data read and written per second by byte per second.

Iops is the io per second, the number of IO per second.

The bps and iops of the container can be controlled by the following parameters:

-- device-read-bps, which restricts reading the bps of a device.

-- device-write-bps, which restricts writing to the bps of a device.

-- device-read-iops, which restricts reading the iops of a device.

-- device-write-iops, which restricts writing to the iops of a device.

The following example limits the rate at which containers can write / dev/sda to 30 MB/s

Docker run-it-- device-write-bps / dev/sda:30MB ubuntu

Let's take a look at the experimental results.

Test the speed of writing the disk in the container through dd. Because the container's file system is on host / dev/sda, writing files in the container is equivalent to writing to host / dev/sda. In addition, oflag=direct specifies that the file is written in direct IO so that-- device-write-bps can take effect.

The results show that the bps 25.6 MB/s does not exceed the speed limit of 30 MB/s.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report