The attributes and resources of Mesos
Mesos describes the slave nodes present in the cluster by the following two methods:
Attributes
Attributes are used to describe certain additional information regarding the slave node, such as its OS version, whether it has a particular type of hardware, and so on. They are expressed as key-value pairs with support for three different value types—scalar, range, and text—that are sent along with the offers to frameworks. Take a look at the following code:
attributes : attribute ( ";" attribute )* attribute : text ":" ( scalar | range | text )
Resources
Mesos can manage three different types of resources: scalars, ranges, and sets. These are used to represent the different resources that a Mesos slave has to offer. For example, a scalar resource type could be used to represent the amount of CPU on a slave. Each resource is identified by a key string, as follows:
resources : resource ( ";" resource )* resource : key ":" ( scalar | range | set ) key : text ( "(" resourceRole ")" )? resourceRole : text | "*"
Predefined uses and conventions
The Mesos master predefines how it handles the following list of resources:
cpus
mem
disk
ports
In particular, a slave without the cpu
and mem
resources will never have its resources advertised to any frameworks. Also, the master's user interface interprets the scalars in mem
and disk
in terms of MB. For example, the value 15000
is displayed as 14.65GB
.
Here are some examples of configuring the Mesos slaves:
resources='cpus:24;mem:24576;disk:409600;ports:[21000-24000];bugs:{a,b,c}'
attributes='rack:abc;zone:west;os:centos5;level:10;keys:[1000-1500]'
In this case, we have three different types of resources, scalars, a range, and a set. They are called cpus
, mem
, and disk
, and the range type is ports
.
- A scalar called
cpus
with the value24
- A scalar called
mem
with the value24576
- A scalar called
disk
with the value409600
- A range called
ports
with values21000
through24000
(inclusive) - A set called
bugs
with the valuesa
,b
, andc
In the case of attributes, we will end up with three attributes:
- A
rack
attribute with the text valueabc
- A
zone
attribute with the text valuewest
- An
os
attribute with the text valuecentos5
- A
level
attribute with the scalar value10
- A
keys
attribute with range values1000
through1500
(inclusive)