In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Several containers run on a docker host, each of which requires CPU, memory, and IO resources. For virtualization technologies such as KVM,VMware, users can control how much CPU and memory resources are allocated to each virtual machine. For containers, Docker provides a similar mechanism to prevent one container from consuming too much resources to affect the performance of other containers and even the entire host.
Memory limit
Similar to the operating system, the memory available to the container consists of two parts: physical memory and swap. Docker controls container memory usage through the following two sets of parameters.
1,-m or-- memory: set the memory usage limit, such as 100m, 2G.
2.-- memory-swap: set the usage limit of memory + swap.
When we execute the following command:
Docker run-m 200m-- memory-swap=300M ubuntu
The implication is to allow the container to use up to 200m of memory and 100m of swap. By default, the above two sets of parameters are-1, which means there are no restrictions on the use of container memory and swap.
Next we will use the progrium/stress image to learn how to allocate memory to the container. This image can be used to perform pressure tests on the container. Execute the following command:
Docker run-it-m 200m-memory-swap=300M progrium/stress-- vm 1-- vm-bytes 280m
-- vm 1: starts a memory worker thread.
-- vm-bytes 280m: each thread allocates 280m of memory.
The running results are as follows:
Because 280m is within the assignable range (300m), the worker thread can work properly, and the process is:
Allocate 280m of memory. Free 280m of memory. Re-allocate 280m of memory. Release another 280m of memory. It circulates all the time.
If the worker thread allocates more than 300m of memory, the result is as follows:
The allocated memory exceeds the limit, the stress thread reports an error, and the container exits.
If you specify only-m instead of-- memory-swap when starting the container, then-- memory-swap defaults to twice the-m, for example:
Docker run-it-m 200m ubuntu
The container uses up to 200m physical memory and 200m swap.
This is the end of the discussion on the memory limit. 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.