DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Resource Management for Your Docker Service

Resource Management for Your Docker Service

Don't let a rogue Docker container starve others of CPU and memory in your cloud instance.

Kasia Hoffman user avatar by
Kasia Hoffman
·
Aug. 01, 16 · Tutorial
Like (2)
Save
Tweet
Share
3.51K Views

Join the DZone community and get the full member experience.

Join For Free

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 Is Resource Management in Docker 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. Read more about Multi-tenancy Docker Stacks here.

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 constraints/resources directive.

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 service.yml commands.

Example:


services:  
    <service_name>:
        constraints:
            resources:
                memory: "100m"
                cpu: 512


Note:Ubuntu v14.04 only supports applying the memory limits to RAM usage. Ubuntu v16.04 additionally supports limiting 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”.

Related Refcard:

Getting Started With Docker

Docker (software)

Published at DZone with permission of , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Real-Time Stream Processing With Hazelcast and StreamNative
  • Securing VMs, Hosts, Kubernetes, and Cloud Services
  • Top 10 Best Practices for Scaling Your Application: Expert Tips for Optimizing Performance and Ensuring Reliability
  • The Importance of Delegation in Management Teams

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: