In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to limit Docker container resources". In daily operation, I believe many people have doubts about how to limit Docker container resources. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to limit Docker container resources". Next, please follow the editor to study!
Memory--memory can be used alone, but-- memory-swap must be used with-- memory. Normally, the value of-- memory-swap contains the container's available memory and the available swap. So-- memory= "300m"-- memory-swap= "1g" means that the container can use 300m of physical memory and can use 700m (1G-300m) swap. -- memory-swap is the sum of the physical memory that the container can use and the swap that can be used! Setting-- memory-swap to 0 is the same as not setting-- at this time, if-- memory is set, the container can use twice the swap size of-- value. If the value of-- memory-swap is the same as-- memory, the container cannot use swap. If-- memory-swap is not set,-- memory is set, the container can use swap of twice the-- memory capacity. -- memory= "300m"-- memory-swap is not set, which is equivalent to using 300m memory + 600m swap. If-- memory-swap is set to-1, the capacity of the swap is not limited, but it will be limited by the swap capacity of the host host inside the container. The swap seen by free is the swap of the host, not the available swap capacity of the container-- oom-kill-disable when OOM occurs, the kernel will kills the processes in the container. To change this behavior, you can set-- memory at the same time as-- oom-kill-disable. If-memory is not set, host may OOM, and the kernel will kill host the system process to release memory
Java memory allocation, because java programs can set their own jvm stack size when the program starts, so how to deal with the container memory limit and the jvm itself memory limit is a problem. Java has also been updated rapidly in recent years, with the temperament of version Emperor, and different jdk versions have different levels of support for containers.
Java8u131- specifies the stack size java8u131+ java9-XX:+UnlockExperimentalVMOptions-XX:+UseCGroupMemoryLimitForHeapjava10-XX:-UseContainerSupportCPU by setting the-Xmx parameter inside the container
There are two kinds of CPU scheduling of Docker, one is CFS scheduling, the other is realtime scheduling.
CFS:CFS is the default cpu scheduling policy for ordinary processes in the linux kernel.
Realtime scheduling is also supported after Realtime:docker1.13, and a later version of the kernel is required.
CFSdocker-1.13+-- the number of cpus, which can be a decimal, indicating the number of cpu that can be used by the container docker-1.13- cpu-period and-- cpu-quota units in milliseconds, and combined to indicate the number of cpu that the container can use. Cpus is the integration of these two commands-- cpuset-cpus binding cpu, which allows the container to run on a fixed host cpu-- cpu-shares sets the weight of each container to cpu. The default is 1024. Setting to 0 means to use the default value 1024Realtime
You need to see if the kernel supports the addition of the-- cpu-rt-runtime parameter when the CONFIG_RT_GROUP_SCHED,Docker daemon starts.
-- cap-add=sys_nice--cpu-rt-runtime=--ulimit rtprio= at this point, the study on "how to restrict Docker container resources" 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.
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.