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 docker restricts the cpu of containers

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

Share

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

This article to share with you is about docker how to limit the cpu of the container, Xiaobian feel quite practical, so share to everyone to learn, I hope you can gain something after reading this article, not much to say, follow Xiaobian to see it.

How does docker limit the cpu of a container? One of Docker's great features is that it can isolate and limit various resources, including CPU, memory, network, hard disk, etc.

As you can see from Docker's official documentation, when starting a container with Docker run, you can control the use of CPU by the container with the three parameters-cpu-shares -cpu-period and-cpu-quota.

-cpu-shares

By default, all containers share the same, that is, all containers have the same weight. When all containers compete for resources together, the final resource is the same.

This share is a relative value, so the meaning of this value can not be simply through the share value of a container, but a number of comparisons together, such as A and B two containers, A configuration is 1024, B configuration is 512, then A can use up to twice the CPU resources of B. One more thing to note is that this configuration is flexible, if container A is idle, container B can use free resources.

cpu-period and cpu-quota

These two parameters are put together because they match each other. - cpu-period and-cpu-quota are called Ceiling Enforcement Adjustable Parameters, and-cpu-shares are called Relative Shares Adjustable Parameters.

-cpu-period is used to specify how long the CPU usage of the Kubernetes Engine should be reallocated, and-cpu-quota is used to specify the maximum amount of time that can be used to run the container in this cycle. Unlike-cpu-shares, this configuration specifies an absolute value, and there is no elasticity in it. The container will never use CPU resources more than the configured value.

For example, if container A is configured with-cpu-period=100000 -cpu-quota=50000, then container A can use up to 50% CPU resources. If the configuration is-cpu-quota=200000, then it can use 200% CPU resources.

The above is how docker limits the CPU of the container. Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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