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 does Docker restrict the Block IO use of containers

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces "how Docker restricts the use of Block IO in containers". In daily operation, I believe many people have doubts about how Docker restricts the use of Block IO in containers. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how Docker limits the use of Block IO in containers". Next, please follow the editor to study!

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 600ubuntu 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.

As a comparative test, if there is no speed limit, the results are as follows:

At this point, the study on "how Docker restricts the use of Block IO in containers" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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