0

I am running my application as a docker container in both Docker Swarm UCP (using compose.yml file) as well as in Mesos (using marathon.json file).

I have added the resource constraints in both the files.

compose.yml:

resources:
  limits:
    cpus: '0.50'
    memory: 50M
  reservations:
    cpus: '0.25'
    memory: 20M

marathon.json:

"cpus": 0.50,
"mem": 128.0,
"disk": 5.0

What I found out is memory is the hard limit and cpu is the soft limit. i.e. cpu limit is only for weight and priority. If mesos cpu is 1 and if two applications are running one with 0.4 cpu and the other with 0.6 cpu then app one will get 40% of the cpu cycles and app two will get 60% of the cpu cycles.

Then what is the use of limit and reservation in compose.yml file here?

Now I am trying to understand below things

  1. How does this resource constraints work exactly?

  2. What happens when the container exceeds these values?

sachin
  • 1,220
  • 1
  • 14
  • 24
Anil Kumar R
  • 283
  • 1
  • 4
  • 12

1 Answers1

0

reservations means that the container won't start on a node of that node doesn't have enough free resources to respect this constraint.

limits means that when a process in the container reaches that limit and tries to allocate more it will be forcefully killed.

Constantin Galbenu
  • 16,951
  • 3
  • 38
  • 54