We're thrilled to announce Resource Management for Docker Services general availability on Cloud 66. This add-in gives you the tools to help control the CPU and memory usage of your services.
Why Resource Management in Docker is useful?
Prioritization of services:
You may host multiple services on one server, where one service is more important than another. You may have an instance where one of the services exceeds the memory or CPU available, which would potentially result in failure of all services on the server. To prevent this from happening, you can prioritize the secondary service to fail and allow the rest of the services to be healthy and active. Also, you are able to set limits on how much memory or CPU usage each service is allowed to consume, this provides more uniform scheduling and limits waste.
Host multiple applications on one server
By limiting each service to a specific amount of memory and CPU usage, you can run multiple applications on your server without each eating into the others resources, allowing a smoother running experience for all apps.
Resource Management for Docker Services with Cloud 66
It's often unclear how resource management across Docker containers actually works. By default, Docker services will use as much CPU or memory as they require. However, you can also manually set a hard limit on memory or the relative CPU shares used by a service. This can be accomplished with the
The default number of CPU shares given to a service is 1024. This is a relative number, for example, when you have two containers (container A and container B). The service of container A has 1024 CPU shares, and the service of container B has 512 CPU shares with both containers attempting to use 100% of the CPU. In such a case container B will receive half of the total CPU time. This only applies when CPU-intensive tasks are running, so if one container is idle then the others can use the remaining CPU time.
You can specify and set up the limits of memory and CPU by using
services: <service_name>: constraints: resources: memory: "100m" cpu: 512
Note: Ubuntu v14.04 would only support the memory limits for RAM usage. Ubuntu v16.04 memory limit will additionally support swap usage for the given containers. A valid entry is a positive number, followed by one of “b”, “k”, “m”, or “g”, with the minimum being “4m”.