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?
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.