Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give an example for --reserve-memory #325

Closed
wants to merge 1 commit into from
Closed

Give an example for --reserve-memory #325

wants to merge 1 commit into from

Conversation

mdlinville
Copy link
Contributor

Carrying moby/moby#32631

Incorporated feedback from that PR.

@codecov-io
Copy link

codecov-io commented Jul 12, 2017

Codecov Report

Merging #325 into master will decrease coverage by 0.15%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #325      +/-   ##
==========================================
- Coverage   48.84%   48.68%   -0.16%     
==========================================
  Files         186      186              
  Lines       12413    12416       +3     
==========================================
- Hits         6063     6045      -18     
- Misses       5976     5996      +20     
- Partials      374      375       +1

on an approach.

On Linux, you can also limit a service's overall memory footprint on a given
host, `cgroups` or other mechanisms at the level of the operating system.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having trouble understanding this sentence; I think maybe a word is missing somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, "using" is missing.

schedule a service on a host that doesn't have enough memory. `--limit-memory`
will limit the service's memory to stay within that limit, so if every service
has a memory-reservation and limit set, Docker services won't saturate the
host.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this over-promises slightly - even if all services have memory reservations and limits, there could still be other non-containerized (or non-service container) software on the host using memory, as you point out earlier, which would cause Docker to exhaust the available memory.

@aaronlehmann
Copy link
Contributor

Overall this is very good. It's a difficult topic to explain.

I think the most important thing to get across is that the scheduler doesn't look at actual measurements of real-time memory use. It only pays attention to the reservations. So there's no magic that makes sure enough memory is available before scheduling a container on a certain host - it's entirely up to the operator to specify reservations, and make sure that the reserved memory will actually be available (for example, by limiting service memory use as well). The text does a good job of explaining this.

I would also add special emphasis on the danger of mixing services with reservations and services without reservations. Since a service without a memory reservation doesn't have any memory reserved for it, the scheduler would still be able to schedule that service to a node where all the memory is reserved. If you want to use memory reservations, it's important to use them for all services, otherwise the services without reservations can negate the careful work you did to keep memory usage under control.

Signed-off-by: Misty Stanley-Jones <misty@docker.com>
@mdlinville
Copy link
Contributor Author

Addressed feedback. PTAL again.

If your service needs a minimum amount of memory in order to run correctly,
you can use `--reserve-memory` to specify that the service should only be
scheduled on a node with this much memory available to reserve. If no node is
available that meets the criteria, the service is not scheduled, but remains in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the task is not scheduled"


On Linux, you can also limit a service's overall memory footprint on a given
host at the level of the host operating system, using `cgroups` or other
relevant operating system tools.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to confirm it's possible to do this at the host OS level for a swarm service. ping @crosbymichael @justincormack

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably by creating a cgroup, and setting it as parent-cgroup on the daemon

@nevmerzhitsky
Copy link

Finish this change guys, please. The community have a lot of issues with limiting resources for containers. In the swarm especially. IMO

@thaJeztah
Copy link
Member

carried in #2316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants