Mesos Container
Mesos container is the default containerizer for launching task in Mesos. It comes with different level of isolations e.g. posix/cpu,posix/mem, cgroups/cpu, cgroups/mem, etc. These isolators can be passed to Mesos slave by the command line argument --isolation
or as a config file namedisolation
under Mesos slave conf directory.
To start a task using Mesos
mesos-execute --command="sleep 10" --name="test-mesos-container" --master=MASTER_IP:5050
If you do a ps auxf
on the slave that run the task, you will see a tree hierarchy
TBD
Each Mesos task is launched inside its own isolated work directory which contains container's stdout and stderr. All Mesos stdout and and stderr will be streamed to these 2 files.
Isolators
A Mesos Isolator provides lightweight resource isolation of executors using Linux-specific functionality such as control cgroups and namespaces. It is composable so operators can selectively enable different isolators.
By default, Mesos provides basic support for POSIX systems (posix/cpu, posix/mem). These isolators only provide resource usage reporting.
To enable memory constraint, use cgroup/mem.
This isolator make sure OOM exception is raised whenever memory is exceed which effectively kill the Mesos container process along with all its child processes.
cgroup/cpu
use cpu.share feature of cgroups (https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/sec-cpu.html). Each task is allocated a portion of CPU time based on some weighted values. E.g. if there are 2 task running on a Mesos slave, task A has cpu.share=0.1, and task B has cpu.share=0.2. The scheduler will likely allocate 66% available CPU time to process B and 33%. Note that these number don't map directly to CPU time but is calculated intelligently based on what's running. You find more details about resource sharing in below excellent blog posts:
- https://zcox.wordpress.com/2014/09/17/cpu-resources-in-docker-mesos-and-marathon/
- http://datastrophic.io/resource-allocation-in-mesos-dominant-resource-fairness-explained/
Mesos doesn't yet support cpu.set so there is no way to dedicate a CPU for a task.
More on Mesos containerizer
http://mesos.apache.org/documentation/latest/mesos-containerizer/