I am reading Building Applications on Mesos, and come across the following statements:
cpus
This resource expresses how many CPU cores are available. Tasks may use fractional parts of a CPU—this is possible because Mesos slaves use CPU shares, rather than reserving specific CPUs. This means that, if you have 1.5 cpus reserved, your processes will be allowed to use a total of 1.5 seconds of CPU time each second. That could mean that, within a single executor, two processes each get 750 milliseconds of CPU time per second, or one process gets 1 second of CPU time and another gets 500 milliseconds of CPU time each in a given second. The benefit of using CPU shares is that if some task would be able to utilize more than its share, and no other task would use an otherwise idle CPU, the first task can potentially use more than its share. As a result, the cpus reserved provides a guaranteed minimum of CPU time available to the task—if additional capacity is available, it will be allowed to use more.
I can't understand "if you have 1.5 cpus reserved, your processes will be allowed to use a total of 1.5 seconds of CPU time each second.
". How can it use 1.5
seconds of CPU
time each second?
Apache Mesos is a platform that allows effective resource sharing between such applications. In this article, we'll first discuss a few problems of resource allocation within applications deployed on the same cluster. Later, we'll see how Apache Mesos provides better resource utilization between applications. 2. Sharing the Cluster
The cpu constraint is used to set the cpu share weight/priority for the application on the slave, it defines how the apps (containers) will share the cpu time. The cpu constraint is used to “select” offers from slaves and “reserve” the resource on selected slave. Again look at the mesos source code:
A Mesos cluster must run an agent on every machine. These agents report their resources to the master periodically and in turn, receive tasks that an application has scheduled to run. This cycle repeats after the scheduled task is either complete or lost.
Resources are used to publish hardware information of the agent machine such as memory, CPU, and disk. There are five predefined resources for every Agent: The values for these resources can be defined in one of the three types: By default, Mesos agent tries to detect these resources from the machine.
By utilizing more than one cpu/core :-).
Note that the actual behavior/enforcement of these limits will highly depend on the actual containerizer/isolator used. Unfortunately I could not find any good/recent documentation (but I know that there are people working on improving this :-) ), but you could have a look at this blog post: Blog Post about CPU resources
Update
There is als hard cap on the CPU utilization: See the
--[no]-cgroups_enable_cfs
configuration parameter
or this Jira.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With