In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
In the previous section, you learned how to limit the use of memory by containers. In this section, we take a look at CPU.
By default, all containers can use host CPU resources equally and without restrictions.
Docker can set the weight of CPU used by the container with-c or-- cpu-shares. If not specified, the default value is 1024.
Unlike the memory limit, the cpu share set with-c is not the absolute number of CPU resources, but a relative weight value. The CPU resources that a container can eventually be allocated depend on its cpu share as a percentage of the total cpu share of all containers.
In other words: through cpu share, you can set the priority for the container to use CPU.
For example, two containers are launched in host:
Docker run-name "container_A"-c 1024 ubuntudocker run-name "container_B"-c 512 ubuntu
Container_A 's cpu share 1024 is twice that of container_B. When both containers require CPU resources, container_A can get twice as much CPU as container_B.
It is important to note that this weighted CPU only occurs when CPU resources are tight. If container_A is idle, container_B can also be allocated to all available CPU in order to make full use of CPU resources.
Let's continue to experiment with progrium/stress.
1. The startup container_A,cpu share is 1024:
Cpu is used to set the number of worker threads. Because there is only one CPU in the current host, a worker thread can fill up the CPU. If the host has more than one CPU, you need to increase the number of cpu accordingly.
2. The startup container_B,cpu share is 512:
3. Execute top in host to check the container's use of CPU:
Container_A consumes twice as much CPU as container_B.
4. Pause container_A now:
5. Top shows that container_B can use the whole CPU when container_A is idle:
CPU limit is discussed here, the above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.